Programming tips – Rockwell Automation 2708-DH5B2L_DH5B4L Attended Workstation User Manual

Page 145

Advertising
background image

Programming Conventions and Tips

Appendix J

VBASIC Language Development Kit

J–2

Always put a semicolon ( ; ) on the end of PRINT statements when writing to
the second line of the display or scrolling will occur. Always check for the
semicolon before running the program since they are easy to leave off.

Use PC1 and PC2 (in READ.BAS) to print centered strings on the first and
second lines of the display.

When using Read... and Menu%, with timeouts, make sure to set
TIMEOUT% and GLOBALMASK% before each call. While they are not
modified by these routines, you may frequently find yourself calling a
routine which changes them.

An alternate way to use TIMEOUT%, GLOBALMALSK% and
GLOBALATTR% is to set them to the most comonly used values at the start
of your program. Then, any routine which changes these values should save
the prior value and restore it after use.

Note: The GLOBALMASK% variable should be assigned a value of 0 for
keyboard only READs, 1 for keyboard READs which can timeout in
TIMEOUT% 100ths of a second, or a 2 for READs from both the keyboard
and bar code scanner with a timeout.

If you need your READ to wait for more than 0, 1, or 2 can accomplish, then
you must compose GLOBALMASK by (OR)ing together values from:
KbdMask, TimeoutMask, BadgeMask, Mask, NetMask, ComMask,
AuxMask.

Example:

GLOBALMASK% = NetMask OR TimeoutMask

So, what’s the common error? Since the read statement returns a value of
TimeoutEvent or NetEvent, you might code:

GLOBALMASK% = NetEvent OR TimeoutEvent ‘ ! ! ! WRONG ! ! !

The READ.BAS module contains subroutines whose purpose is formatted
input from the keyboard. If you enable the Badge Mask and use ReadStr,
ReadInt or another read function, the data must be retrieved from InbBuf$ if
e = BadgeEvent. See the details of ReadStr for a sample program.

Programming Tips

Advertising
This manual is related to the following products: