Intermec PC43d Fingerprint Developer's Guide (PC23d, PC43d/t, PM23c, PM43, PM4 - Page 29

About Branching, Branching to Subroutines

Page 29 highlights

Chapter 2 - Understanding Fingerprint Syntax Example: 10 TIME$ = "121500":FORMAT TIME$ "HH:MM" 20 A%=VAL(TIME$) 30 IF A%>120000 THEN 40 PRINT "TIME IS ";TIME$("F"); ". "; 50 PRINT "GO TO LUNCH!" 60 ELSE 70 PRINT "CARRY ON - "; 80 PRINT "THERE'S MORE WORK TO DO!" 90 END IF RUN This results in (for example): TIME IS 12:15. GO TO LUNCH! About Branching Both conditional and unconditional branching is possible in Fingerprint. • For information on conditional branching, see the next section. • For information on unconditional branching, see "Unconditional Branching Using a GOTO Statement" on page 20. • For information on branching to subroutines, see the next section. Branching to Subroutines A subroutine is a range of program lines intended to perform a specific task separately from the main program execution. For example, branching to subroutines can occur when: • an error condition occurs. • a condition is fulfilled, such as a certain key being pressed or a variable obtaining a certain value. • a break instruction is received. • background communication is interrupted. You can also branch to a subroutine from different places in the same program. You only need to write the routine once, making the program more compact. The instruction for unconditional branching to subroutines is the GOSUB statement. After branching, the subroutine is executed line by line until a RETURN statement is encountered. The same subroutine can be branched to as often as needed from different lines in the main program. GOSUB remembers where the last branching took place, which makes it possible to return to the correct line in the main program after the subroutine has been executed. Subroutines may be nested, which means that a subroutine may contain a GOSUB statement for branching to a secondary subroutine. Subroutines should be placed on lines with higher numbers than the main program. Append the main program with an END statement to avoid unintentional execution of subroutines. Fingerprint Developer's Guide 17

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 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
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163

Chapter 2 — Understanding Fingerprint Syntax
Fingerprint Developer’s Guide
17
Example:
10
TIME$ = “121500”:FORMAT TIME$ “HH:MM”
20
A%=VAL(TIME$)
30
IF A%>120000 THEN
40
PRINT “TIME IS ”;TIME$(“F”); ”. ”;
50
PRINT “GO TO LUNCH!”
60
ELSE
70
PRINT “CARRY ON - ”;
80
PRINT “THERE’S MORE WORK TO DO!”
90
END IF
RUN
This results in (for example):
TIME IS 12:15. GO TO LUNCH!
About Branching
Both conditional and unconditional branching is possible in Fingerprint.
For information on conditional branching, see the next section.
For information on unconditional branching, see
“Unconditional Branching
Using a GOTO Statement” on page 20
.
For information on branching to subroutines, see the next section.
Branching to Subroutines
A subroutine is a range of program lines intended to perform a specific task
separately from the main program execution. For example, branching to
subroutines can occur when:
an error condition occurs.
a condition is fulfilled, such as a certain key being pressed or a variable obtaining
a certain value.
a break instruction is received.
background communication is interrupted.
You can also branch to a subroutine from different places in the same program. You
only need to write the routine once, making the program more compact.
The instruction for unconditional branching to subroutines is the GOSUB
statement. After branching, the subroutine is executed line by line until a RETURN
statement is encountered.
The same subroutine can be branched to as often as needed from different lines in
the main program. GOSUB remembers where the last branching took place, which
makes it possible to return to the correct line in the main program after the
subroutine has been executed. Subroutines may be nested, which means that a
subroutine may contain a GOSUB statement for branching to a secondary
subroutine.
Subroutines should be placed on lines with higher numbers than the main program.
Append the main program with an END statement to avoid unintentional
execution of subroutines.