The text of a manual · part 4 of 26
Videx BASIC for DuraTrax, LaserLite, LaserLite Pro, and LaserLite Mx Data Collectors, pages 31 to 40
Pages 31 to 40 of 252
The original document is the PDF (765 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 Videx DuraTrax, Videx LaserLite, Videx LaserLite Mx and Videx LaserLite Pro
Page 31
If the ASCII codes differ, the lower code number precedes the higher. If the end of one string is reached during string comparison, the shorter string is smaller if they are equal up to that point. Leading and trailing blanks are significant. Following are examples of true string expressions: "AA" < "AB" "FILENAME" = "FILE" + "NAME" "CL " > "CL" "kg" > "KG" "SMYTH" < "SMYTHE" B$ < "9/12/78" 'where B$ = "8/12/85"
String comparisons can be used to test string values or to alphabetize strings. All string constants used in comparison expressions must be enclosed in quotation marks.
Chapter 3 Expressions & Operators
23
Page 32
Notes:
24
Chapter 3 Expressions & Operators
Page 33
Chapter 4 Statement & Function Reference This chapter is a dictionary of the Videx BASIC statements and functions for the DuraTrax, LaserLite, LaserLite Pro, and LaserLite Mx data collectors. Please note that the following statements and functions are not supported by the Macintosh version of the Videx BASIC compiler: BIN function, CARDCMD statement, CARDSTATUS function, HEX$ function, and TOUCH statement. Each entry follows the following format: •= Action - Summarizes what the statement or function does. •= Syntax - Shows the model syntax. •= Parameters - Describes the variables used in the syntax. •= Remarks - Descriptions of arguments, options, and use. •= Returns - Value returned (functions only). •= Example - An example using the function or statement line. Note: In the examples, the statements CLS, SLEEP, and LOCATE are used to control the data collector’s display. They are for effect only and may be ignored if you wish. SLEEP 0 halts program execution until a key is pressed. Following is a summary of the symbols used to define the syntax of the Videx BASIC functions and statements program lines: •= Terminal symbols are bold. These are to be typed in “as is.” •= Variables are in italics. •= Variables that are assigned return values are in UPPERCASE ITALICS. •= [ ] enclose optional items. •= { } enclose items to repeat 0 or more times. •= ( ) enclose groups of items. •= The pipe character ( | ) separates alternatives. Chapter 4 Statement & Function Reference
25
Page 34
ABS Function • Action Returns the absolute value of a numeric expression. • Syntax result% = ABS ( intexp% ) • Parameters Argument intexp%
Description Any whole number from -32768 to 32767.
• Remarks The absolute value function returns the unsigned magnitude of its argument. For example, ABS (-1) and ABS (1) are both 1. • Returns The unsigned value of intexp% as an integer. • Example REM ABS() Function DIM result%,intexp% CLS intexp% = -1 PRINT "Value of intexp% is:" PRINT intexp%; SLEEP 0 'pause screen until keypress CLS 'clear the screen result% = ABS(intexp%) PRINT "ABSolute is:" PRINT result%; SLEEP 0
Output: ABSolute is: 1
26
Chapter 4 Statement & Function Reference
Page 35
ASC Function • Action Returns the ASCII code of the first character in the string. • Syntax result% = ASC ( strexp$ ) • Parameters Argument strexp$
Description Any string expression.
• Remarks See also CHR$. The CHR$ function complements ASC. • Returns The ASCII code of the first character in strexp$ as an integer. • Example REM ASC() Function DIM strexp$,result% FOR i = 1 TO LEN("VIDEX") strexp$ = MID$("VIDEX",i,1) result% = ASC(strexp$) CLS PRINT "ASCII for "; strexp$; " is:" PRINT result%; SLEEP 0 'pause screen until keypress NEXT i
Chapter 4 Statement & Function Reference
27
Page 36
BEEP Statement • Action Sounds the beeper. • Syntax BEEP • Parameters None • Remarks The BEEP statement makes a sound through the beeper. This statement is the same as: SOUND 1028, 100 See also SOUND. • Example REM BEEP Statement CLS PRINT "This is a beep!" BEEP SLEEP 0 CLS PRINT "This is :" PRINT "SOUND 1028,100"; SOUND 1028,100 SLEEP 0
28
Chapter 4 Statement & Function Reference
Page 37
BIN Function • Action Converts hexadecimal digits to the corresponding integer value. (Videx BASIC) (Note: This function is not supported by the Macintosh version of the Videx BASIC compiler.) • Syntax result% = BIN ( hex_string$, num_digits% ) • Parameters Argument hex_string$ num_digits%
Description String variable containing hexadecimal digits to process at the beginning of the string. A hexadecimal digit can be either uppercase or lowercase. Number of characters to convert (0 to 4). If zero is specified, only the number of valid hexadecimal digits encountered (up to 4) will be converted.
• Remarks The last character converted (moving left to right) is always the leastsignificant nibble (4 bits) of the result. The more significant characters are leftmost in the string. For example, consider the two source strings FACES and 3C2GT, the respective results for various num_digits% values would be: hex_string$ FACES
3C2GT num_digits% 0 1 2 3 4 0 1 2 3 4 result% -1330 15 250 4012 -1330 962 3 60 962 -1
(FACE hex) (000F hex) (00FA hex) (0FAC hex) (FACE hex) (03C2 hex) (0003 hex) (003C hex) (03C2 hex) (error - too few digits)
Chapter 4 Statement & Function Reference
29
Page 38
The compiler flags any out-of-range values for num_digits%. If the parameter is supplied by a variable, any out-of-range values are forced into range by the formula: good
=
( (bad - 1) MOD 4 ) + 1
For example, a value of 5 becomes 1 (see Example 1) and a value of 19 becomes 3 (see Example 2). Note: MOD arithmetic provides the remainder of an integer division, rather than the quotient. For example: 16 MOD 5 = 1: 16 ÷ 5 = 3 with a remainder 1; 3250 MOD 256 = 178: 3250 ÷ 256 = 12 with a remainder of 178. See page 18 for complete information on MOD arithmetic. •= Example 1 good = ( (5 - 1) MOD 4) + 1 good = (4 MOD 4) + 1 good = (0) + 1 good = 1 •= Example 2 good = ( (19 - 1) MOD 4) + 1 good = (18 MOD 4) + 1 good = (2) + 1 good = 3 The BIN function is similar to the ASC function, except that it interprets pairs of hexadecimal digit characters (two per byte) as an integer rather than giving just the ASCII value of an individual character. See also ASC, HEX$, and TOUCH. • Returns Returns the value of the first num_digits% hexadecimal digits in the string. If num_digits% is not zero and there are fewer digits than specified, or if one of the characters of the required number is not a valid hexadecimal digit, the function returns (-1). A legitimate value of FFFF can be verified by string comparison. 30
Chapter 4 Statement & Function Reference
Page 39
• Example REM BIN()and HEX$ Functions DIM hex_data$ * 4 DIM i%, number% FOR i% = 1 to 10 number% = i% * 50 hex_data$ = HEX$ (number%, 0) 'convert to hex CLS PRINT str$ (number%); " in hex:" PRINT hex_data$; 'display result SLEEP 0 number% = bin (hex_data$, 0) 'convert back to decimal CLS PRINT hex_data$; " as decimal:" PRINT str$ (number%); 'display result SLEEP 0 NEXT i% END
Chapter 4 Statement & Function Reference
31
Page 40
CARDCMD Statement (for LaserLite Mx only) • Action Constructs and sends commands to the memory card processor, adding required overhead and integrity elements. (Videx BASIC) (Note: This statement is not supported by the Macintosh version of the Videx BASIC compiler.) • Syntax CARDCMD cmd_letter[!][, param_1 [, param_2 [, param_3]]] or CARDCMD command_str$ • Parameters Argument cmd_letter param_x
32
Description A single letter that signifies the command to the memory card processor. Case is not significant. CRC checking is always used for this form of the command. Follow the letter immediately (no space) with an exclamation mark for commands that may take some time; the system does not wait for the result and retrieves it only when the CARDSTATUS command is issued. The default is to retrieve the result immediately after issuing the command (before returning). Special case: To activate a hardware reset of the memory card processor, this parameter should be an integer constant or variable with the value (-1). These are parameters appropriate to the command to be executed. There can be zero or one string parameter, and if present it must be the last parameter. All parameters can be constants, variables, or expressions. The integer parameters can be specified (for CARDCMD only) by a single letter. The value is then interpreted to be the ASCII value of the letter, with case being significant. A side effect of this feature is that any integer parameters cannot begin with a variable name consisting of a single letter.
Chapter 4 Statement & Function Reference