The text of a manual · part 23 of 25
Attended Workstations (Catalog Nos. 2708-DH5B2L & -DH5B4L) (Series B) User Manual, pages 162 to 167
Pages 162 to 167 of 186
The original document is the PDF (513 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Allen-Bradley 2708
Page 162
Appendix L Differences Between A-B VBASIC and Visual BASIC
RETURN Returns control from a sub routine. No line number or line label clauses are supported in A-B VBASIC.
RIGHT$(stringexpression, n) Returns the rightmost n characters of a string. A$ = “Now is the time for all good men to come to the aid of” B$ = RIGHT$(A$, 6) ‘B$ = “aid of”
RND Returns a single–precision random number between 0 and 1. No argument is allowed in the statement. To produce random integers in a given range, use the following formula: INT((upperrange – lowerrange + 1) * RND + lowerrange)
RTRIM$(stringexpression) Returns a string with trailing (right–hand) spaces removed. A$=”When I was younger, so much younger than today A$=RTRIM$(A$) ‘Removes trailing spaces.
“
SEEK(filenumber) Returns the current file position. See the chapter on Special Devices for details on specific devices. See VBDOS manual for detailed information.
SEEK [#]filenumber,position Sets the position in a file for the next read or write. See the chapter on Devices for details on specific devices.
SELECT CASE text_expression Executes one or more statements depending on the value of text expression. The CASE ELSE clause is mandatory in A-B VBASIC, even if it does nothing. See VBDOS manual for specific details. SELECT CASE text_expression CASE expressionlist1 statements CASE expressionlist2 statements CASE ELSE L–15
Page 163
Appendix L Differences Between A-B VBASIC and Visual BASIC statements END SELECT
SGN(numeric–expression) Indicates the sign of a numeric expression. See VBDOS manual for specific details.
SHARED variable [AS type] [,variable [AS type]]... Gives a SUB or FUNCTION procedure access to variables declared at the module level without passing them as parameters. All arrays in the SHARED statement must have been previously DIMensioned in module level code. LXB also requires non–arrays to have previously appeared at the module level. See example on next page. ‘Module level code... DIM Datain AS STRING DO LINE INPUT; Datain CALL ShowDatain LOOP ‘Sub–routine SUB ShowDatain SHARED Datain AS STRING LOCATE 1, 1, 0 PRINT Datain; END SUB
SLEEP seconds Suspends execution of the calling program. Seconds may be a non–integer, unlike VBDOS. Sleep continues until the specified number of seconds have elapsed completely. Unlike VBDOS, the DH5 program will NOT wake up early if a key is pressed. ON COM, ON TIMER, and forms are not supported, so references to those in the VBDOS manual are irrelevent. The EGG timer will be disabled when a SLEEP statement is used. SLEEP 5 ‘Suspends execution for 5 seconds.
In A-B VBASIC, fractional second delays are supported to a resolution of 1/100ths of a second. This is different from VBDOS, where delays under .5 are rounded down to zero, suspending program execution indefinitely.
SOUND frequency,duration Generates sound through the speaker. In the DH5, the correspondence between the “frequency” specification and the true sound of that frequency is approximate. Also, in certain firmware versions, unlike VBDOS, the sound is initiated and the program continues without waiting for the sound to complete. L–16
Page 164
Appendix L Differences Between A-B VBASIC and Visual BASIC
SOUND 1400, 2 ’1400 Hz for 2 clock ticks (20 ticks per second).
SPACE$(n) Returns a string of spaces of length n. X = 25 A$ = SPACE$(X) ‘A$ equals 25 spaces.
STATIC variablelist Makes simple variables or arrays local to either a FUNCTION, or a SUB and preserves values between calls. See VBDOS manual for detailed information. For arrays, STATIC must precede DIM. Also any AS clauses must match. A single variable in STATIC may NOT also appear in a DIM.
STOP Terminates the program. Status Display #8 will indicate “End by system”. No arguments are allowed. VBDOS manual references to compiler options and line numbers are irrelevent. See also SYSTEM.
STR$(numeric–expression) Returns a string representation of the value of a numeric expression. The format of the strings returned by A-B VBASIC may not be identical to those returned by VBDOS. For example, given STR$(1.0), VBDOS will return 1, but A-B VBASIC will return 1.000000. X% = 1234 S$ = STR$(X%) ‘S$ equals “ 1234”.
STRING$(m,n) STRING$(m,stringexpression) Returns a string whose characters all have a given ASCII code or whose characters are all the first character of a string expression. See VBDOS manual for specific details. Header$ = STRING$(80,”*”) ‘Header$ equals 80 asterisks.
SUB globalname[(parameterlist)][STATIC] ... ... END SUB Marks the beginning and end of a subprogram. See also STATIC. L–17
Page 165
Appendix L Differences Between A-B VBASIC and Visual BASIC
SUB GetName (Name$) DO CLS LINE INPUT “Enter your name: “;Name$ PRINT Name$;“Correct? “; LINE INPUT; YN$ YN$ = UCASE$(YN$) YN$ = “Y” or YN$ = “” THEN EXIT DO LOOP END SUB
SWAP vari1,vari2 Exchanges the values of two variables. See VBDOS manual for specific details. Versions 1.0/1.1 of DH5 firmware do not support swapping single or double precision variables. This will be corrected by future versions. A$ = “1234” B$ = “4321” SWAP A$, B$ ‘A$ = “4321”, B$ = “1234”
SYSTEM Terminates program execution. END, STOP, and SYSTEM as well as “reaching the bottom” of a A-B VBASIC program all have the same result: the program is terminated. Program termination causes the following: Files are left unchanged. In particular, if HOST was OPEN, it remains OPEN; Status Display #8 and the corresponding read–only menu display show “End by System”, and the offset in the program where the termination occurred; An error: “BASIC ERROR: End by System” is transmitted to the HOST; Any “End by System” error message with an offset of 0 (zero) is serious and should be reported.
TIME$ Returns the current time from the operating system. An 8 byte string is returned in the form hhmmssnn, representing hours(0–23), minutes, seconds, and hundredths of a second. (The Clock Mode setting of the Setup Menus has no effect on the format of the TIME$ variable.) CurrTime$ = TIME$
TIME$ = stringexpression Sets the time. See preceding entry. This method of setting the actual time is in addition to the Setup Menus and the Network Directives which allow the host to set the time. See also DATE$. L–18
Page 166
Appendix L Differences Between A-B VBASIC and Visual BASIC
TIME$ = “15450000” ‘ Sets time to 3:45:00.00
TIMER Returns the number of seconds elapsed since midnight. As a single precision value this is accurate to 1/100th of a second. Measurements with this function can be in error if they span midnight. See also the EGG device. StartTime = TIMER FOR X = 1 TO 500: NEXT X EndTime = TIMER Elapsed = EndTime – StartTime
TYPE usertype elementname AS typename elementname AS typename
END TYPE Defines a data type containing one or more elements. An element cannot be the name of an array. TYPE EmpType Badge AS STRING * 8 Name AS STRING * 25 CodeNum AS INTEGER END TYPE
UBOUND(array[,dimension]) Returns the upper bound (largest available subscript) for the indicated dimension of an array. See VBDOS manual for specific details.
UCASE$(stringexpression) Returns a string expression with all letters in uppercase. A$ = UCASE$(“Now is the time for all...”) A$ now contains: NOW IS THE TIME FOR ALL...
VAL(stringexpression) Returns the numeric value of a string of digits. See VBDOS manual for specific details. CheckAmt$ = “123.45” Amount = VAL(CheckAmt$)
‘Amount will now contain 123.45
WHILE condition ...[statements] L–19
Page 167
Appendix L Differences Between A-B VBASIC and Visual BASIC
WEND Executes a series of statements in a loop, as long as a given condition is true. A-B VBASIC does impose a nested loop limit which should not be exceeded under normal programming conditions. WHILE INKEY$ = “”: WEND ‘Loops until a key is pressed.
WRITE #filenumber [,expressionlist] Writes data to a file in memory. See the chapter on Special Devices for details on specific devices.
L–20