Rockwell Automation 2708-NBD VBASIC Language Development Kit User Manual

Page 60

Advertising
background image

A-B VBASIC and Visual BASIC

Appendix B

Differences Between

B–12

OPEN “COM” FOR INPUT AS #1 ‘Must be a normal terminal.
DO

DO WHILE LOC(1) = 0: LOOP ‘Wait for any data in the buffer
R$ = INPUT$(1, #1)
Rx$ = Rx$ + R$
i = INSTR(Rx$, CHR$(13))

‘Look for a carriage return.

IF i > 0 THEN

Datain$ = LEFT$(Rx$, i – 1)

‘Read in data

CLS
PRINT Datain$;

‘Display it

Rx$ = “”: R$ = “”

‘Clear the temporary buffer

END IF

LOOP

LOCATE[row][,[column][,[cursor]]]

Moves the cursor to the specified position. The start and stop arguments do
not apply to A-B VBASIC.

LOCATE 2, 1

‘Position cursor on line 2

PRINT “Hello world”;

‘Use of semicolon prevent scrolling

LOCATE 1, 1, 0

‘Position cursor on line 1

PRINT “Goodbye world”;

LOF(filenumber)

Returns the length of the named file in bytes. The REMARKS paragraph in
the VBDOS manual applies only to some A-B VBASIC devices. See the
chapter on Special Devices for details about specific devices.

OPEN “POWER” FOR INPUT AS #1
IF LOF(1) > 0 THEN

‘If file contains data,

Powerfail = TRUE

then there must have been a power failure

ENDIF

LTRIM$(stringexpression)

Returns a copy of a string with the leading spaces removed.

A = 100
A$ = LTRIM$(STR$(A)) ‘Removes leading space in front of 100.

MID$(stringexpression, start[, length])

Returns a substring of a string. See VBDOS manual for detailed
information. See also MID$ statement, (replaces a portion of a string
variable with another string.)

A$ = “Now is the time for...”
B$ = MID$(A$, 8, 3) ‘B$ now equals “the”.

MKD$, MKI$, MKL$, MKS$

(MKD$ is no longer supported) Converts numeric values to string values.
See VBDOS manual for detailed information.

Advertising