The text of a manual · part 13 of 26
Videx BASIC for DuraTrax, LaserLite, LaserLite Pro, and LaserLite Mx Data Collectors, pages 121 to 130
Pages 121 to 130 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 121
'* '* '* '* '* '* '* fn_power description: Respond to a power event. These events are generated when the power switch is turned off. Respond by putting the data collector into a low-power state.
fn_power: OPTION(256) = 0 SOUND 4300, 500 SOUND 3300, 500 SOUND 2300, 500 SOUND 1300, 500 SLEEP 0 OPTION(256) = 1
'turn off the LCD (not needed for Mx)
'sleep indefinitely 'turn LCD back on (not needed for Mx)
RETURN get_origin: IF device% = 1 THEN origin$ = "keyboard" ELSEIF device% and 14 THEN 'laser or contact scanner IF symbol% = 1 THEN origin$ = "USS-39" ELSEIF symbol% = 2 THEN origin$ = "UPC" ELSEIF symbol% = 4 THEN origin$ = "USS-I 2/5" ELSEIF symbol% = 8 THEN origin$ = "Codabar" ELSEIF symbol% = 16 THEN origin$ = "EAN" ELSEIF symbol% = 64 THEN origin$ = "UCC Code 128" ELSEIF symbol% = 128 THEN origin$ = "USS 128" ELSE origin$ = "unknown" ENDIF ELSEIF device% and 48 THEN 'touch button origin$ = LEFT$(data$, 2) 'get the family code, add 30 origin$ = "button type " + STR$(30 + VAL(origin$)) data$ = RIGHT$(data$, 12) 'convert data into ROM code ELSE origin$ = "unknown" ENDIF RETURN
Chapter 4 Statement & Function Reference
113
Page 122
INSTR Function • Action Returns the character position of the first occurrence of a string in another string. • Syntax position% = INSTR ( [start%,] stringexpression1$, stringexpression2$ ) • Parameters Argument start% stringexpression1$ stringexpression2$
Description An optional offset that sets the position for starting the search; start% must be an integer in the range 1– 32767. If start% is not given, the INSTR function begins the search at the first character of stringexpression1$. The string being searched. The string to search for.
The arguments stringexpression1$ and stringexpression2$ can be string variables, string expressions, or string literals. See also LEN, MID$, LEFT$, and RIGHT$. • Remarks Searches for an occurrence of stringexpression2$ in stringexpression1$. Use the LEN function to find the length of stringexpression1$.
114
Chapter 4 Statement & Function Reference
Page 123
• Returns The value returned by INSTR depends on the following conditions: Condition stringexpression2$ found in stringexpression1$ start% greater than length of stringexpression1$ stringexpression1$ is null string stringexpression2$ cannot be found stringexpression2$ is null string
Returned Value The position where the match is found. 0 0 0 start% (if given); otherwise 1
• Example REM INSTR() Function data$ = "two words" CLS PRINT "Splitting..." PRINT data$; SLEEP 3 blankPosition% = INSTR(1,data$," ") firstWord$ = LEFT$(data$,blankPosition%-1) secondword$ = RIGHT$(data$,LEN(data$) - blankPosition%) CLS PRINT "Word 1 is ";firstWord$ PRINT "Word 2 is ";secondWord$; SLEEP 3 END
Output: Splitting... two words Word 1 is two Word 2 is words
Chapter 4 Statement & Function Reference
115
Page 124
LCASE$ Function • Action Returns a string with all letters in lowercase. • Syntax word$ = LCASE$ ( stringexpression$ ) • Parameters Argument stringexpression$
Description The string to lowercase. This can be a string variable, string constant, or string expression.
• Remarks LCASE$ is helpful in string comparison operations where tests need to be case insensitive. See also UCASE$. • Returns The string in lowercase letters. • Example REM LCASE$() Function word$ = "LOWERCase" PRINT word$ word$ = LCASE$(word$) PRINT word$; SLEEP 0
Output: LOWERCase lowercase
116
Chapter 4 Statement & Function Reference
Page 125
LEFT$ Function • Action Returns a string that is composed of the leftmost characters in the string argument. • Syntax word$ = LEFT$ ( stringexpression$, n% ) • Parameters Argument stringexpression$ n%
Description Any string variable, string constant, or string expression. An integer expression (range 0–32767) indicating how many characters are to be returned.
• Remarks See also INSTR, LEN, MID$, and RIGHT$. • Returns If n% is greater than the number of characters in stringexpression$, the entire string is returned. To find the number of characters in stringexpression$, use the LEN function. If n% is zero, a null string (length zero) is returned.
Chapter 4 Statement & Function Reference
117
Page 126
• Example 1 REM LEFT$() Function example 1 word$ = "BASIC LANGUAGE" PRINT word$ B$ = LEFT$(word$,5) 'get first 5 characters (should be BASIC) PRINT B$; SLEEP 0 'pause display until keypress B$ = RIGHT$(word$,8) 'get last 8 characters (should be LANGUAGE) LOCATE 1,0 PRINT B$; SLEEP 0 'pause display until keypress
Output: BASIC LANGUAGE BASIC LANGUAGE
• Example 2 REM LEFT$() Function example 2 data$ = "two words" CLS PRINT "Splitting..." PRINT data$; SLEEP 3 'pause display for 3 seconds or keypress blankPosition% = INSTR(1,data$," ") firstWord$ = LEFT$(data$,blankPosition%-1) secondword$ = RIGHT$(data$,LEN(data$) - blankPosition%) CLS PRINT "Word 1 is ";firstWord$ PRINT "Word 2 is ";secondWord$; SLEEP 3 END
Output: Splitting... two words Word 1 is two Word 2 is words
See also INSTR example.
118
Chapter 4 Statement & Function Reference
Page 127
LEN Function • Action Returns the number of characters in a string. • Syntax length% = LEN ( stringexpression$ ) • Parameters Argument stringexpression$
Description Any string variable, string constant, or string expression.
• Remarks See also INSTR, LEFT$, MID$, and RIGHT$. • Returns The number of characters in the argument stringexpression$. • Example REM LEN() Function LET word$ = "Videx DuraTrax" PRINT word$ lenWord% = LEN(word$) length$ = STR$(lenWord%) PRINT "is "; length$; " chars."; SLEEP 0 'pause display until keypress
Output: Videx DuraTrax is 14 chars.
Chapter 4 Statement & Function Reference
119
Page 128
LET Statement • Action Assigns the value of an expression to the named variable. • Syntax 1 [ LET ] variable$ = stringexpression$ • Syntax 2 [ LET ] variable% = integerexpression% • Parameters Argument variable$ variable% stringexpression$ integerexpression%
120
Description The name of a string variable where the result of the string expression will be copied. The name of an integer variable to receive the value of the integer expression. A string constant, variable, or single value obtained by combining constants, variables, and other expressions with operators. An integer constant, variable, or single value obtained by combining constants, variables, and other expressions with operators.
Chapter 4 Statement & Function Reference
Page 129
• Remarks The keyword LET is optional. The equal sign in the statement is enough to inform BASIC that the statement is an assignment statement. However, it is somewhat faster to compile code that uses the LET statement and the compiled program is identical. Both stringvariable$ and integervariable% can be an element of an array. The corresponding lines, in the following two program fragments, perform the same functions: LET D=12 LET E=12-2 LET F=12-4 LET SUM=D+E+F
D=12 E=12-2 F=12-4 SUM=D+E+F
. . .
. . .
• Example REM LET() Statement LET newLine$ = CHR$(13) + CHR$(10)
'carriage return/ 'line feed combination
PRINT "Line 1"; newLine$; "Line 2"; SLEEP 0 'pause display until keypress
Output: Line 1 Line 2
Chapter 4 Statement & Function Reference
121
Page 130
LOCATE Statement • Action Moves the cursor to the specified row and column. • Syntax LOCATE row%, column% • Parameters Argument row% column%
Description The number of a row on the screen; row% is an integer number. The number of a column on the screen; column% is an integer number.
• Remarks The rows and columns are numbered from 0. The first character of the next PRINT statement will be at the designated location. • Example 1 LOCATE 0,0
LOCATE 1,5
'Moves cursor to the upper-left corner (1st 'character position) of the first line on the 'display. 'Moves cursor to the 6th character position of 'the second line on the display.
• Example 2 REM LOCATE Statement PRINT "This line fixed" 'displayed on line 1 PRINT "This line changes..."; 'displayed on line 2 SLEEP 0 FOR i% = 1 TO 10 LOCATE 1,0 'position cursor at start of line 2 PRINT "New Line ";i%;" "; 'print on line 2 SLEEP 1 'a 1 second delay for reading NEXT i% SLEEP 0 'press key to exit
122
Chapter 4 Statement & Function Reference