The text of a manual · part 22 of 26
Videx BASIC for DuraTrax, LaserLite, LaserLite Pro, and LaserLite Mx Data Collectors, pages 211 to 220
Pages 211 to 220 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 211
'* '* evt_esc '* description: Escape key was pressed (LaserLite Pro/Mx). '* evt_esc: sound 1397, 10 'click so the user knows we got the key cls print "Escape key" print "was pressed."; n_times% = 1 gosub kill_time return '* '* evt_mem '* description: Memory key was pressed (LaserLite Pro/Mx). '* Display remaining available RAM. '* evt_mem: sound 1397, 10 'click so the user knows we got the key cls print environ$(1); " free"; n_times% = 2 gosub kill_time return '* '* evt_bat '* description: Battery key was pressed (LaserLite Pro/Mx). '* Display battery voltage. '* evt_bat: sound 1397, 10 'click so the user knows we got the key cls print environ$(0); " volts"; n_times% = 2 gosub kill_time return
Appendix C Sample BASIC Programs
203
Page 212
'* '* evt_f1 '* description: F1 key was pressed (LaserLite Pro/Mx). '* evt_f1: sound 1397, 10 'click, so the user knows we got the key cls print "F1 key was" print "pressed."; n_times% = 1 gosub kill_time return '* '* evt_f2 '* description: F2 key was pressed (LaserLite Pro/Mx). '* evt_f2: sound 1397, 10 'click, so the user knows we got the key cls print "F2 key was" print "pressed."; n_times% = 1 gosub kill_time return
204
Appendix C Sample BASIC Programs
Page 213
'* '* evt_f3 '* description: F3 key was pressed (LaserLite Pro/Mx). '* evt_f3: sound 1397, 10 'click, so the user knows we got the key cls print "F3 key was" print "pressed."; n_times% = 1 gosub kill_time return '* '* evt_f4 '* description: F4 key was pressed (LaserLite Pro/Mx). '* Display operating system. '* evt_f4: sound 1397, 10 'click, so the user knows we got the key bar$ = environ$(2) cls print left$ (bar$, 16) if len(bar$) > 16 then print right$ (bar$, len(bar$)-16); endif n_times% = 2 gosub kill_time return
Appendix C Sample BASIC Programs
205
Page 214
'* evt_delete '* description: F5 key was pressed (LaserLite Pro/Mx) '* or a 5 space barcode was scanned. '* Delete most recent entry. evt_delete: if lof(0) = 0 then 'see if there is any data in file sound 2349,250 cls print "There is no data" print "to delete!"; n_times% = 4 gosub kill_time return endif seek #0, 0, e 'move pointer to end of data file bar$ = token$ (0, delimiter$, backward%) cls print "Delete data? Y" bar2$ = mid$ (bar$, 21) 'remove date and time foo% = len (bar2$) if foo% <= 14 then print bar2$; locate 1,14: print " N"; else print ".."; right$ (bar2$, 12); " N"; endif gosub questiontone do foo% = asc(inkey$()) loop until (foo% = 2) | 'up arrow or (foo% = 4) | 'down arrow or (foo% = 89) | rem 'Y' or (foo% = 78) | rem 'N' or (foo% = 132) | rem MEM (Y unshifted) or (foo% = 42) | rem '*' (N unshifted) if (foo%=2) or (foo%=89) or (foo%=132) then nbytes% = len (bar$) + 2 'delete <cr/lf> characters gosub truncate gosub deletetone display$ = token$(0, delimiter$, backward%) if display$ = "" then display$ = "-TOP OF DATA-" mode = mode_norm% else display$ = mid$(display$, 21)'remove date & time mode% = mode_up% endif full_display$ = display$ shift% = 0 else sound 2349, 250 endif return
206
Appendix C Sample BASIC Programs
Page 215
'* '* check_voltage '* description: Get the current voltage. If it is below '* low_voltage% and has changed, alert the user. '* check_voltage: bar$ = left$(environ$(0), 3) foo% = (val(left$(bar$, 1)) * 10) + val(right$(bar$, 1)) if foo% < low_voltage% then if foo% < voltage% then cls print "Low batteries." print environ$(0) ; " volts" ; gosub ring sleep 10 voltage% = foo% end if else voltage% = foo% end if return '* '* '* '* '* '* evt_pfail description: It looks like power was lost when the unit was not asleep. This event is generated once if the unexpected loss of power can be detected.
evt_pfail: cls print "Power loss," print "verify data."; gosub ring sleep 0 return '* '* ring '* description: Ring to alert the user of an error. '* ring: for ring_i% = 1 to 10 sound 2093, 50 sound 2794, 50 next ring_i% return
Appendix C Sample BASIC Programs
207
Page 216
'* '* delete tone '* description: Tone that indicates that a record has '* been deleted. '* deletetone: sound 3620,150 sound 2349,250 return '* '* questiontone '* description: Tone used when asking user to confirm if '* data is to be deleted. '* questiontone: sound 2349, 150 sound 3620, 250 return '* '* scroll_info '* description: Display various information when you have '* scrolled down to the bottom of the data file. '* scroll_info: info_index% = info_index% + 1 if 3 < info_index% then info_index% = 0 end if on info_index% gosub os_info, volt_info, time_info, mem_info return volt_info: 'display battery voltage display$ = environ$(0) + " volts" return os_info: 'display operating system name display$ = environ$(2) return time_info: 'display time display$ = time$() return mem_info: 'display available RAM display$ = environ$(1) + " free" return
208
Appendix C Sample BASIC Programs
Page 217
'* '* truncate '* description: Remove nbytes% from the data file. '* truncate: if nbytes% <= 0 then return 'nbytes% must be positive end if high% = lofh( 0) 'get the size of the file in low% = lof( 0) 'high and low words if nbytes% <= low% then low% = low% - nbytes% 'if the low word is >= nbytes%, then 'just subtract nbytes% from low word elseif 0 < high% then 'otherwise, if the high byte isn't zero, high% = high% - 1 'subtract one from the high byte and set low% = ((low% - nbytes%) + 32767) + 1 'the low byte to low% + 32768 - nbytes% else 'otherwise, the file isn't nbytes% long high% = 0 low% = 0 endif lof( 0) = high%, low% 'set the new file length return '* '* kill time '* description: Delays program operation while information '* is being displayed. '* kill_time: for foo% = 1 to (n_times% * x_delay%) next foo% return
Appendix C Sample BASIC Programs
209
Page 218
MXDEMO.B The following BASIC program demonstrates the functionality of a LaserLite Mx and accesses the LaserLite Mx memory card. ' MXDEMO.B ' This program demonstrates the functionality of a ' LaserLite Mx. The main application writes data to a file ' and allows scrolling and deleting. In addition, another ' routine called by the <F1> key, gets a number in a ' sequence, appends it to clock data, writes it to a file on ' the memory card, reads it back and displays it. Another ' routine, invoked by pressing <F3>, offers to search for ' one of the sequence numbers in the database. ' 'define constants const false% = 0 const true% = not false% const backward% = true% const forward% = false% const mode_norm% = 0 'defines scrolling behavior const mode_up% = 1 const mode_dn% = 2 const mode_bottom% = 3 const mode_top% = 4 const low_voltage% = 45 'voltage to trigger warnings const x_delay% = 150 'define delay time dim data$ * 64 'dimension strings dim display$ * 64 dim full_display$ * 64 dim bar$ * 64 dim bar2$ * 64 dim buffer_var$ * 256 dim voltage% dim info_index% dim shift% dim running% dim mode% dim n_times% dim cstatus$ dim cardreturn$ * 256 dim crdcmd$ * 256
210
Appendix C Sample BASIC Programs
Page 219
beginning: mode% = mode_norm% running% = true% voltage% = 60 info_index% = 0 shift% = 0 NL$ = chr$(13) + chr$(10) 'carriage return/line feed sound 2793, 250 'startup beep sound 2637, 250: sound 2793, 250 open "dataram.txt" for append as #0 'open & name data file cls print "Starting"; NL$; "application...."; cardcmd O, 2203, I, "data.txt" 'open a data file on the memory card gosub process_cardcmd_error 'report errors from sending command to card print #0, "cardresult% = "; str$(cardresult%) IF crderr% = 0 THEN cardresult% = cardstatus(cardreturn$) 'get results gosub process_card_error 'handle any errors ELSE goto won't_work ENDIF data$ = "" display$ = "" cardcmd C, S gosub process_cardcmd_error cardresult% = cardstatus(cardreturn$) 'determine file handle being used and record it in dhandle$ 'so we can be sure it is the only one that allows user entry gosub process_card_error chandle$ = mid$(cardreturn$,14,2) dhandle$ = chandle$ 'initialize variables while running% 'event loop gosub check_voltage 'check battery voltage cls print left$(display$, 16) 'display a prompt print "Scan: "; inputevt 6, 1, 16, 2, type%, symbol%, device%, data$ 'get event on type% gosub fn_null, fn_input, fn_exit,| evt_delete, fn_up, fn_down, fn_power, evt_pfail,| evt_esc, fn_null, evt_nomodule, evt_nocard,| evt_badcard, evt_cardID, evt_card_interrupted,| fn_null, fn_null, fn_null, fn_left, fn_right,| evt_mem, evt_bat, evt_f1, evt_f2, evt_f3, evt_f4,| evt_delete 'process the event wend sound 1760, 200 'exit beep sound 1568, 200 sound 1397, 200 end 'return to command line
Appendix C Sample BASIC Programs
211
Page 220
'* '* fn_null '* description: Do nothing function. '* fn_null: return '* '* '* '* '* '* '* fn_input description: Respond to a user input event by beeping and blinking the valid scan LED, and appending the input to the end of the data file along with the current date and time.
fn_input: if device% = 1 then if len(data$) = 0 then 'it's an ENTER key, with no data sound 698, 250 'sound a low beep return endif endif cardcmd F%, data$ 'search for data$ in data file gosub process_cardcmd_error cardresult% = cardstatus(cardreturn$) if (cardresult% = 35) then 'data not found in data file option(258) = 1 'turn on the LED sound 1446, 250 'good beep option(258) = 0 'turn off the LED record$ = data$ + chr$(09) + time$ + chr$(09) + date$ 'build a record with fields that are tab delimited IF dhandle$ <> chandle$ THEN gosub just_open 'be sure we are going to write to correct file cardcmd A, record$ 'append the record gosub process_cardcmd_error cardresult% = cardstatus(cardreturn$) gosub process_card_error display$ = data$ 'display the input on the screen mode = mode_dn% 'same as if we had just scrolled 'down to the last line of file full_display$ = data$ 'initialize for scroll right & left shift% = 0 elseif (cardresult% <> 0) then gosub process_card_error else 'duplicate scan, do not accept it cls locate 0,0 print data$ print "already scanned"; gosub card_error_tone 'n_times% = 1 'gosub kill_time
212
Appendix C Sample BASIC Programs