Rockwell Automation 2708-NBD VBASIC Language Development Kit User Manual

Page 56

Advertising
background image

A-B VBASIC and Visual BASIC

Appendix B

Differences Between

B–8

may not return the same file numbers, even in identical programs. Just
because a file number is unassigned does not imply that a new file can be
created. There is a maximum number of files which can exist, open or not.
See the Limits section for specifics on A-B VBASIC file and device
limitations.

IF NumFilesOpen < 15 THEN NextFileNum = FREEFILE

FUNCTION name[(parameterlist)][STATIC]

Declares the name, the parameters, and the code that form the body of a
FUNCTION. The appearance of a FUNCTION’s name on the right side of an
= or in an argument list, is considered to be a call to that function, with or
without an “(argument list)”. Do not use FUNCTION procedures that
perform I/O in I/O statements.

CurrTime$ = GetTime$
FUNCTION GetTime$()

GetTime$ = TIME$

END FUNCTION

GET [#]filenumber[,[recordnumber][,variable]]

Reads data from a file in memory into a variable. All 3 items after GET are
required, however the record number can be consecutive commas as in, GET
#1,,V$. See the chapter on Special Devices for details about input from
specific devices. FIELD is not supported, use TYPE..END TYPE.

TYPE EmpType

Badge AS STRING * 8
Name AS STRING * 25

END TYPE
DIM SHARED Emp AS EmpType
OPEN “EMPLOYEE” FOR RANDOM AS #1 LEN = LEN(Emp)
Rec = 0
DO WHILE NOT EOF(1)

Rec = Rec + 1
GET #1, Rec, Emp
IF Emp.Badge = BadgeInput$ THEN Found = TRUE: EXIT DO

LOOP
CLOSE #1

GOSUB {linelabel | linenumber}....RETURN

Branches to and returns from a sub–routine. Linelabel on RETURNs are not
supported in A-B VBASIC. BASIC’s SUB and FUNCTION procedures
provide a more well–structured alternative to GOSUB...RETURN
subroutines.

DO

CurrTime$ = LEFT$(GetTime$,4)
IF CurrTime$ > OldTime$ THEN

GOSUB UpdateTime
OldTime$ = CurrTime$

Advertising