Intermec PX4i Fingerprint Developer's Guide (old) - Page 38
About Loops, Using a FOR...NEXT Instruction
View all Intermec PX4i manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 38 highlights
Chapter 2 - Understanding Fingerprint Syntax About Loops • RESUME NEXT - Execution is resumed at the statement immediately following the one that caused the error. • RESUME - Execution is resumed at the specified line. • RESUME - Execution is resumed at the specified line label. This example shows branching to a subroutine when an error has occurred. The subroutine determines the type of error and takes the appropriate action. In this example only one error ("1019 Invalid font") is checked. After the error is cleared by substituting the missing font, the execution is resumed. 10 20 30 40 1000 1010 1020 1030 1040 1050 1060 2000 2010 ON ERROR GOTO 1000 PRTXT "HELLO" PRINTFEED END IF ERR=1019 THEN FONT "OCR-A BT" ELSE GOTO 2000 PRINT "Substitutes missing font" FOR A%=1 TO 3 SOUND 440,50 SOUND 359,50 NEXT A% RESUME PRINT "Undefined error, execution terminated" END RUN One type of loop has already been described in connection with the GOTO statement, where GOTO referred to the same line or a previous line. There are two instructions for using more advanced loops: Using a FOR...NEXT Instruction These statements create loops in which a counter is incremented or decremented until a specified value is reached. The counter is defined by a FOR statement as follows: FOR=TO [STEP]NEXT[] All program lines following the FOR statement are executed until a NEXT statement is encountered. Then the counter (specified by a numeric variable) will be updated according to the optional STEP value (or by the default value +1) and the loop is executed again. This is repeated until the final value, as specified by TO , is reached. Then the loop is terminated and the execution proceeds from the statement following the NEXT statement. FOR...NEXT loops can be nested, which means a loop can contain another loop. Each loop must have a unique counter designation in the form of a numeric variable. The NEXT statement makes the execution loop back to the most recent FOR statement. To loop back to a different FOR statement, the corresponding NEXT statement must include the same counter designation as the FOR statement. This example shows how five lines of text entered from the host keyboard can be printed with an even spacing: 22 Intermec Fingerprint Developer's Guide