Rockwell Automation 2708-DH5B2L_DH5B4L Attended Workstation User Manual

Page 153

Advertising
background image

A-B VBASIC and Visual BASIC

Appendix L

Differences Between

L–6

OPTION BASE is not supported, so in order to set the lower subscript use
the following: DIM A(lower TO upper) if zero is not preferred as the lowest
subscript.

A declaration using AS precludes variables of the same name, even with type
suffixes. For example, NumOfBytes! = 10 will cause an error if there was a
preceding DIM NumOfBytes AS INTEGER

DIM SHARED ON$, OFF$, Now AS INTEGER

DO...LOOP [{WHILE/UNTIL} booleanexpression]

Repeats a block of statements WHILE a condition is TRUE or UNTIL a
condition becomes TRUE.

DO: X = X + 1: LOOP WHILE X < 200

END [{FUNCTION/IF/SELECT/SUB/TYPE}]

Ends a BASIC program, procedure, or block. See FUNCTION, IF, SELECT,
SUB, and TYPE for the particular statement being ended. See VBDOS
manual for detailed information. See Also SYSTEM.

EOF(filenumber)

Tests for the end of file condition. See the chapter on Special Devices for
details about specific devices....

Effect of EOF on a sequential file: TRUE is returned whenever the file

position is = file length. (End–of–File is reached)

Effect of EOF on binary or random files: TRUE is returned if the previous

GET did not get “all” the data that was requested.

For random reads, “all” means the number of bytes specified as the
LENgth in the OPEN, or the variable’s size, whichever is less.

For binary reads, “all” means the size of the variable.

The difference between binary/random and sequential mode is that, in the
former, EOF returns FALSE even though the next GET might not return any
data. Therefore, for binary and random files, do a GET but then test EOF. If
TRUE is returned, the variable does not contain a full record and may not
contain anything at all. Subsequent calls to EOF will continue to return
TRUE. EOF “latches” in this state until a SEEK operation is performed.
Some statements also reset this latch because they do an implied SEEK as
part of their operation. See OPEN example on next page.

OPEN “EMPLOYEE” FOR INPUT AS #1
DO WHILE NOT EOF(1)

LINE INPUT #1, EmpBadge$
IF EmpBadge$ = BadgeInput$ THEN

Advertising
This manual is related to the following products: