The text of a manual · part 12 of 26
Videx BASIC for DuraTrax, LaserLite, LaserLite Pro, and LaserLite Mx Data Collectors, pages 111 to 120
Pages 111 to 120 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 111
The following list describes the parts of the thenpart syntax: Argument statements linelabel
Description One or more BASIC statements, separated by colons ( : ). A valid BASIC line label.
Note that GOTO is required with a line label. Unlike other BASIC implementations, there is no ELSE clause, and only one statement may follow THEN. • Parameters 2 (block) The following list describes the parts of the block form: Argument Booleanexpression1, Booleanexpression2 statementblock-1, statementblock-2, statementblock-n
Description Any expression that evaluates to true (nonzero) or false (zero). One or more BASIC statements on one or more lines.
BASIC executes a block form IF by testing the first Boolean expression (Booleanexpression1). If the Boolean expression is true (nonzero), the statements following THEN are executed. If the first Boolean expression is false (zero), each ELSEIF condition is evaluated in turn. When a true condition is found, the statements following the associated THEN are executed. If none of the ELSEIF conditions are true, the statements following the ELSE are executed. After the statements following a THEN or ELSE are executed, the program continues with the statement following the ENDIF. The ELSE and ELSEIF blocks are both optional. You can have as many ELSEIF clauses as you want in a block IF. Any of the statement blocks can contain nested block IF statements. BASIC looks at what appears after the THEN keyword to determine whether or not an IF statement is a block IF. If anything other than a
Chapter 4 Statement & Function Reference
103
Page 112
comment appears after THEN, the statement is treated as a single-line IF statement. The block must end with an ENDIF statement. ENDIF and ELSEIF statements may contain an optional space; for example: END IF, ELSE IF. • Remarks An IF statement can have any number of ELSEIF clauses, but only one ELSE clause. Both the ELSEIF and ELSE clauses are optional. The single-line form of the statement is best used for short, straightforward tests where only one action is taken. The block form provides several advantages: •= It provides more structure and flexibility than the single-line form by allowing conditional branches across several lines. •= It can test for more complex conditions. •= It lets you use the THEN...ELSE portion of the statement. •= It allows your program’s structure to be guided by logic rather than by how many statements fit on a line. Programs that use block-form IF...THEN...ELSE are usually easier to read, maintain, and debug. The single-line form is never required. Any program using single-line IF...THEN statements can be written using the block form. Note: The syntax of the single-line form is somewhat different in Videx BASIC than in QuickBASIC. • Example See the GOTO example.
104
Chapter 4 Statement & Function Reference
Page 113
INKEY$ Function • Action Retrieves and returns a character from the keyboard buffer. • Syntax thekey$ = INKEY$( ) • Parameters None • Remarks The INKEY$ function returns a one-byte string containing a character read from the input device, or a null string if no character is waiting. The one-character string contains the actual character read from the keyboard. The standard input device is the keyboard. INKEY$ does not echo characters to the screen. (Note: Key combinations are not supported.) See also ASC and VAL. • Returns A one-byte string containing a character read from the input device or a null string if no character is waiting. The one-character string contains the actual character read from the keyboard. The following two tables list the keys and their corresponding ASCII values: DuraTrax/LaserLite Keys Key Scan button Scroll up Scroll down
ASCII Value 1 2 4
Chapter 4 Statement & Function Reference
105
Page 114
LaserLite Pro/LaserLite Mx Keys Key SHIFT (Unshifted) SHIFT (Shifted) Scan button ESC ENTER Backspace 0 1 2 3 4 5 6 7 8 9 . + * / Scroll left Scroll right Scroll up Scroll down F1 F2 F3 F4 F5
ASCII Value 128 129 1 27 13 (Carriage return) 8 48 49 50 51 52 53 54 55 56 57 45 46 43 42 47 130 131 2 4 134 135 136 137 138
Key
ASCII Value
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Space MEM BAT
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 32 132 133
• Example See the GOTO example.
106
Chapter 4 Statement & Function Reference
Page 115
INPUT$ Function • Action Returns a string of characters read from a specified file. • Syntax data$ = INPUT$ ( n%, filenumber% ) • Parameters Argument n% filenumber%
Description The number of bytes to return; this is also the number of bytes the current file position is advanced. The file number used in the OPEN statement.
• Remarks Reads n% bytes from the sequential (data) file. The file is always read directly into some string. If the string’s maximum size is less than the number of requested bytes, then the input is truncated to the maximum size of the string. The current file position is always advanced by the number of bytes read, even if the input is truncated. If INPUT$ is used directly in an assignment statement, then the data is read directly into the assigned string. For example, in the following code sample, a string is allocated with a maximum size of 48 bytes. Then, 48 bytes are read from file 0, and the file position is advanced by 512 bytes. DIM data$ * 48 data$ = INPUT$ (512, 0)
Chapter 4 Statement & Function Reference
107
Page 116
If INPUT$ is used in an expression, then the data is read into a temporary string with maximum size of 128. For example, in the following code sample, a string is allocated with a maximum size of 512 bytes. Then, 128 bytes are read into a temporary string, and the file position is advanced by 512 bytes. Finally, “suffix” is appended to the temporary string and assigned to data$. DIM data * 512 data$ = INPUT$ (512,0) + “suffix”
In general, it is best to allocate a string that is the same size as the number of bytes you want to read, and then fill that string with an assignment statement. DIM data$ * 512 data$ = INPUT$ (512,0)
If you need to use an INPUT$ function in an expression, be sure to read fewer than 128 bytes, so the input isn’t truncated. See also OPEN. The INPUT$ function is used to read from a file in RAM. See the CARDCMD statement to work with files on the LaserLite Mx memory card. • Returns The character string read from the specified file. • Example See the EOF example.
108
Chapter 4 Statement & Function Reference
Page 117
INPUTEVT Statement • Action Waits for an event from the data collector and returns information about the event. (Videx BASIC) • Syntax INPUTEVT left%, top%, right%, bottom%, TYPE%, SYMBOLOGY%, DEVICE%, DATA$ • Parameters Argument left% top% right% bottom% TYPE% SYMBOLOGY% DEVICE% DATA$
Description An integer expression that represents the left side of the screen rectangle where data entry occurs. An integer expression that represents the top of the screen rectangle where data entry occurs. An integer expression that represents the right side of the screen rectangle where data entry occurs. An integer expression that represents the bottom of the screen rectangle where data entry occurs. Variable that returns the type of event. Variable that returns the bar code’s symbology. Variable that returns how the data was captured. String that contains the entered data (max 64 characters).
• Remarks The four parameters (left%, top%, right%, and bottom%) define an area on the display for keypad or scanpad data entries. The rectangle 0, 0, 16, 2 is 16 characters wide, 2 characters tall, and starts in the upper-left corner. Rows and columns are numbered starting at zero, and right% and bottom% can be thought of as the first column and row that are NOT in the input area. If all four parameters are set to zero, it is still possible to enter data using the laser, contact bar code scanner, or Touch Memory button reader. If all four parameters are set to zero and data is entered using the keypad or scanpad, the data is accepted as single characters. While waiting for an event, if nothing happens for 30 seconds, INPUTEVT automatically puts the data collector to sleep. It then sleeps Chapter 4 Statement & Function Reference
109
Page 118
for 25 seconds and wakes for 5 seconds, without turning on the screen, this sleep cycle continues until an event occurs. In most cases, an array element can be used anywhere a variable can. INPUTEVT is an exception; the last four arguments cannot be array elements. • Returns The parameters TYPE%, SYMBOLOGY%, DEVICE%, and DATA$ must be variables. Values are assigned depending on the event that occurs. TYPE% can be one of: TYPE% 1 2 3 4 5 6 7 8 9 10 11 12 13 14 18 19 20 21 22 23 24 25 26
110
Event Input Exit Delete last input (5 space character bar code scanned) Scroll up key pressed Scroll down key pressed Power off Unexpected power loss detected (occurs if the lock switch is not turned off before replacing the batteries) LaserLite Pro or LaserLite Mx ESC key (escape) pressed Scan key pressed and released LaserLite Mx no memory card module found LaserLite Mx no memory card found LaserLite Mx unknown memory card found LaserLite Mx memory card ID has changed LaserLite Mx memory card processor interrupted LaserLite Pro or LaserLite Mx scroll left key pressed LaserLite Pro or LaserLite Mx scroll right key pressed LaserLite Pro or LaserLite Mx MEM key (memory) pressed LaserLite Pro or LaserLite Mx BAT key (battery) pressed LaserLite Pro or LaserLite Mx f1 key pressed LaserLite Pro or LaserLite Mx f2 key pressed LaserLite Pro or LaserLite Mx f3 key pressed LaserLite Pro or LaserLite Mx f4 key pressed LaserLite Pro or LaserLite Mx f5 key pressed
Chapter 4 Statement & Function Reference
Page 119
LaserLite Mx uses all of the TYPE% events; DuraTrax and LaserLite use events 1–7 and 9; and the LaserLite Pro uses 1–9 and 18–26. Note: Event 7 (unexpected power loss detected) is not always detected by the operating system. If event 7 occurs, the application starts running from the beginning and sometimes returns with event 7 the first time it executes INPUTEVT. Any data not yet written to the data file is lost. DEVICE% can be one of: 1 2 12 48 keyboard laser contact scanner button touch
SYMBOLOGY% can be one of: 1 2 4 8 16 64 128
Code 39 UPC-A or UPC-E Interleaved 2 of 5 Codabar EAN UCC Code 128 (starts with reserved character Fn1) Code 128 (standard: no Fn1 character at start)
DATA$ is a string containing the data which is entered. The maximum number of characters in this string is 64; longer input strings are not supported by the operating system. If TYPE% is 1, then the user has entered data. DEVICE% gets the device that was used to enter it, SYMBOLOGY% gets the symbology of the entered data, and DATA$ gets the entered data.
Chapter 4 Statement & Function Reference
111
Page 120
• Example REM INPUTEVT Statement '* '* Reports the origin of data. '* CONST NL$ = CHR$(13) + CHR$(10) 'carriage return/line feed combination running% = 1 display$ = "Waiting for " + NL$ + "you.... " 'preprompt user WHILE running% 'event loop CLS PRINT display$; 'display a prompt INPUTEVT 0, 0, 0, 0, type%, symbol%, device%, data$ 'get event ON type% GOSUB fn_null, fn_input, fn_exit, fn_null, fn_up, fn_dn, fn_power WEND END fn_null: 'description: Do nothing function. RETURN '* '* '* '* '* '* '* fn_input description: Respond to a user input event. Beeps and blinks the Valid Scan LED, and then appends the input to end of the data file, along with current date and time.
fn_input: OPTION( 258) = 1 SOUND 2933, 250 OPTION( 258) = 0 GOSUB get_origin display$ = origin$ + NL$ + data$ RETURN
'turn on the LED 'good beep 'turn off the LED 'display input on screen fn_exit: running% = 0 RETURN
'Respond to an exit event 'Exit events are generated when an unlock 'command is sent to the unit during an 'INPUTEVT statement fn_up: SOUND 3000, 225 RETURN
'Respond to a scroll-up event, notify 'user that we got the keypress fn_dn: SOUND 1000, 225 RETURN
'Respond to a scroll-down event, notify 'user that we got the keypress
112
Chapter 4 Statement & Function Reference