Rockwell Automation 2708-NBD VBASIC Language Development Kit User Manual

Page 62

Advertising
background image

A-B VBASIC and Visual BASIC

Appendix B

Differences Between

B–14

OPEN “EMPLOYEE” FOR APPEND AS #1
Format$ = “$####.##”
A = 123.459
PRINT #1, USING Format$; A ‘Prints A to file #1 as $123.45

PRINT USING formatstring; expressionlist[{,|;}]

Prints strings or numbers using specified format. A field width is 8
characters for the LCD. INTEGERs and LONGs will output with .00 even
if .## is used. If a number is negative, a minus sign(–) will always precede
it. The following formatstring characters are not supported... **, $$, **$,
“,”. See the limits page in the A-B VBASIC manual for the maximum
USING clause and the maximum output of a single PRINT.

Format$ = “$####.##”
A = 123.459
PRINT USING Format$; A ‘Prints A as $123.45

PUT [#]filenumber[,[recordnumber][,variable]]

Writes from a variable or a buffer to a random or binary file. The required
syntax is shown above. Omitting the recordnumber such as PUT #1,
,variable is supported, but omitting both the record number and the variable
is not supported. See the chapter on Special Devices for details on specific
devices. Next page for example...

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 = Rec + 1
Emp.Badge = “1234”
Emp.Name = “Johnathan Q. Doe”
PUT #1, Rec, Emp
CLOSE #1

RANDOMIZE expression

Initializes (re–seeds) the random number generator. The expression is
required and must be numeric. The TIMER function is commonly used to
generate a pseudo–random seed as in the example below:

RANDOMIZE TIMER ‘Re–seeds random number generator.

REM remark
‘ remark

Allows explanatory remarks to be inserted in a program. Both forms of
syntax are supported.

Advertising