Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 10 of 26

Videx BASIC for DuraTrax, LaserLite, LaserLite Pro, and LaserLite Mx Data Collectors, pages 91 to 100

Pages 91 to 100 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 91

END Statement • Action Terminates program. • Syntax END • Parameters None • Remarks By itself, the END statement stops program execution and closes all open files. The data collector returns to the command line, where it is possible to communicate with it over the serial port. You may place END statements anywhere in the program to end program execution. The compiler always assumes an END statement at the conclusion of any program, so omitting an END statement at the end of a program still produces proper program termination. • Example REM END Statement DIM buttonNum% CLS PRINT "PRESS A" PRINT "BUTTON"; DO buttonNum% = ASC(INKEY$()) IF buttonNum% <> 0 THEN BEEP END ENDIF LOOP

Chapter 4 Statement & Function Reference

83

Page 92

ENVIRON$ Function • Action Returns various types of status information about the hardware and environment. . • Syntax result$ = ENVIRON$ ( index% ) • Parameters Argument index%

Description An integer that determines the type of information returned. (0 returns battery voltage, 1 returns available RAM, 2 returns system version, 3 returns unit’s ID)

• Remarks The index% argument determines the type of information returned. See the following table for examples: Index 0 1

Status Battery voltage RAM available

2 3

System version Identifier

Examples 3.65 500 24K 1.0.0 DuraTrax OS 0000000000

The available RAM is returned as bytes up to 1023, higher numbers are returned as K. • Returns Returns a string variable with battery voltage, available RAM, system version, or ID depending on index% used.

84

Chapter 4 Statement & Function Reference

Page 93

• Example REM ENVIRON$() Function DIM result$, envir% result$ = "" FOR envir% = 0 TO 3 result$ = ENVIRON$(envir%) CLS IF envir% = 0 THEN PRINT "BATT VOLTS:" ELSEIF envir% = 1 THEN PRINT "AVAIL RAM:" ELSEIF envir% = 2 THEN PRINT "SYS VERSION:" ELSEIF envir% = 3 THEN PRINT "IDENTIFIER:" ENDIF PRINT result$; SLEEP 0 NEXT envir% CLS

See also LOF function example 1.

Chapter 4 Statement & Function Reference

85

Page 94

EOF Function • Action Tests for the end-of-file condition. • Syntax result% = EOF ( filenumber% ) • Parameters Argument filenumber%

Description The file number used in the OPEN statement (0–31).

• Remarks The EOF function is used to test for the end-of-file condition of a file in RAM. See the CARDCMD statement to work with files on the LaserLite Mx memory card. See also OPEN, LOF, and LOFH. • Returns Returns a -1 if the end of a sequential file has been reached. Note: This actually just returns true if the current file position is at the end of the file (after the last byte, ready to append). So, for example, EOF(0) would return true immediately after executing the statement: SEEK #0, 0, E

86

Chapter 4 Statement & Function Reference

Page 95

• Example REM EOF() Function CONST false = 0,true = NOT false DIM myFile$,i%,data$ myFile$ = "data.txt" OPEN myFile$ FOR APPEND as #0 'this is an output file FOR i% = 1 to 10 'write 10 lines to the file PRINT #0, "LINE "; STR$(i%); "VIDEX DURATRAX" NEXT i% CLOSE #0 PRINT "Saved data to:" PRINT myFile$; SLEEP 0 CLS dataLine$ = "" OPEN myFile$ FOR APPEND as #0 'this is an input file SEEK #0,0 DO WHILE NOT EOF(0) 'when EOF is reached, loop stops data$ = INPUT$(21,0) PRINT data$ SLEEP 1 'pause screen for 1 second or keypress LOOP

Chapter 4 Statement & Function Reference

87

Page 96

ERR Function • Action Returns the most recent error condition. • Syntax isError% = ERR • Parameters None • Remarks Statements that set the error condition are explicitly noted in this documentation. It is recommended that the ERR function be called after any file handling, serial communication, or LaserLite Mx memory card routines that set the error condition. ERR clears the error condition. • Returns 0 if no error; -1 if error is encountered. • Example See the LOF function example 2.

88

Chapter 4 Statement & Function Reference

Page 97

EXIT Statement • Action A control statement that exits a FOR...NEXT loop, WHILE...WEND loop, or a DO...LOOP. (Note: The EXIT statement functions somewhat differently in Videx BASIC than in QuickBASIC.) • Syntax EXIT [ FOR | WHILE | DO ] • Parameters None • Remarks If no loop is specified, exits the innermost enclosing loop of any kind. If a loop type is specified, exits the innermost enclosing loop of the specified kind. • EXIT FOR An EXIT FOR statement may appear only in a FOR...NEXT loop. EXIT FOR transfers control to the statement following the NEXT statement. An EXIT FOR statement transfers out of the immediately enclosing loop when FOR...NEXT loops are nested. • EXIT WHILE The EXIT WHILE statement can be used only inside a WHILE...WEND loop. EXIT WHILE transfers control to the statement following the WEND statement. An EXIT WHILE statement transfers out of the immediately enclosing loop when WHILE...WEND loops are nested.

Chapter 4 Statement & Function Reference

89

Page 98

• EXIT DO The EXIT DO statement can be used only inside a DO...LOOP statement. EXIT DO transfers control to the statement following the LOOP statement. An EXIT DO statement transfers out of the immediately enclosing loop when DO...LOOP statements are nested. See also FOR...NEXT, WHILE...WEND, and DO...LOOP. • Example REM EXIT Statement (using EXIT DO) DIM r%, k%, aKey$ * 4 r% = 1 k% = 0 aKey$ = "" DO r% = r% + 1 k% = ASC(INKEY$()) LOCATE 0,0 PRINT "Loop times " ; r% PRINT "ESC = Any key"; IF r% > 1000 THEN CLS PRINT "Exited on..." PRINT "Loop = " ; r%; EXIT DO ELSEIF k% THEN IF k% = 1 THEN aKey$ = "SCAN" ELSEIF k% = 2 THEN aKey$ = "UP" ELSEIF k% = 4 THEN aKey$ = "DOWN" ENDIF CLS PRINT "You pressed the" PRINT aKey$;" Button"; EXIT DO ENDIF LOOP SLEEP 0

90

Chapter 4 Statement & Function Reference

Page 99

FOR...NEXT Statement • Action Allows a series of instructions to be performed in a loop a given number of times. • Syntax FOR counter% = start% TO end% [STEP increment%] . . . NEXT [ counter% ] • Parameters Argument counter% start% end% increment%

Description An integer variable used as the loop counter. The variable cannot be a record array. The initial value of the counter as an integer. The final value of the counter as an integer. The amount the counter is incremented each time through the loop as an integer. This must be a constant expression.

• Remarks The program lines following the FOR statement are executed until the NEXT statement is encountered. Then the loop counter (counter%) is adjusted by the amount specified by STEP (increment%), and compared with the final value (end%). (If you do not specify STEP, the increment is assumed to be one.) If the loop counter (counter%) is still not greater than the final value (end%), the control branches back to the statement after the FOR statement and the process is completed. When the loop counter (counter%) is greater than the final value (end%), execution continues with the statement following the NEXT statement.

Chapter 4 Statement & Function Reference

91

Page 100

If STEP (increment%) is negative, the loop counter (counter%) is decreased each time through the loop, and the loop executes until the counter is less than the final value (end%). If the starting value (start%) is greater than the ending value (end%), the loop does not execute at all. The following loop executes zero times: FOR I=3 TO 2 PRINT I NEXT I

Do not change the value of a loop variable within the loop. Changing the value can make the program more difficult to read and debug. Assignment to the counter variable within the loop will have unpredictable results. If the name of a variable is used for the TO or STEP variable expressions, then assignment to that variable within the loop will have unpredictable results. The following code fragment illustrates the problems: FOR count% = 1 TO ending% STEP stepping% count% = 10 REM This is bad! ending% = 10 REM This is bad! stepping% = 10 REM This is bad! NEXT count%

See also DO...LOOP and WHILE...WEND. • Example REM FOR...NEXT Statement DIM i% PRINT " Euro " PRINT " Sound "; FOR i% = 1 TO 4 SOUND 4800, 500 '(frequency range 50–8000) SOUND 3300, 500 '(duration range 1–2000(2 seconds)) NEXT i%

92

Chapter 4 Statement & Function Reference