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

Input From Sequential Files, Reading Data to a Variable With INPUT#

Page 57 highlights

Chapter 4 - Managing Input and Output Input From Sequential Files To read from a sequential file (or a communication channel other than the std IN channel), the file must be opened for input and assigned a number, which is used when referred to in other instructions. The number mark (#) is optional. Up to 10 files and devices can be open at the same time. In this example, the file "ADDRESSES" is opened for input as number 1: OPEN "ADDRESSES" FOR INPUT AS #1 After a file or device has been opened for input, use these Fingerprint commands to read the data stored in the file or device: • INPUT# • INPUT$ • LINE INPUT# • CLOSE Reading Data to a Variable With INPUT# INPUT# reads a string of data to a variable. Commas can be used to assign portions of the input to different variables. When reading from a sequential file, the records can be read one after the other by repeated INPUT# statements. The records are separated by commas in the string. Once a record has been read, it cannot be read again until the file has been closed and then opened again. This example reads six records in a file and places the data in six variables: 10 OPEN "QFILE" FOR OUTPUT AS #1 20 PRINT #1, "Record A","a","b","c" 30 PRINT #1, "Record B",1,2,3 40 PRINT #1, "Record C","x";"y";"z" 50 PRINT #1, "Record D,Record E,Record F" 60 CLOSE #1 70 OPEN "QFILE" FOR INPUT AS #1 80 INPUT #1, A$ 90 INPUT #1, B$ 100 INPUT #1, C$ 110 INPUT #1, D$,E$,F$ 120 PRINT A$ 130 PRINT B$ 140 PRINT C$ 150 PRINT D$ 160 PRINT E$ 170 PRINT F$ 180 CLOSE #1 RUN The printer returns: Record A a b c Record B 1 2 3 Record C xyz Record D Record E Record F Fingerprint Developer's Guide 45

  • 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 4 — Managing Input and Output
Fingerprint Developer’s Guide
45
Input From Sequential Files
To read from a sequential file (or a communication channel other than the std IN
channel), the file must be opened for input and assigned a number, which is used
when referred to in other instructions. The number mark (#) is optional. Up to 10
files and devices can be open at the same time.
In this example, the file “ADDRESSES” is opened for input as number 1:
OPEN “ADDRESSES” FOR INPUT AS #1
After a file or device has been opened for input, use these Fingerprint commands to
read the data stored in the file or device:
INPUT#
INPUT$
LINE INPUT#
CLOSE
Reading Data to a Variable With INPUT#
INPUT# reads a string of data to a variable. Commas can be used to assign portions
of the input to different variables. When reading from a sequential file, the records
can be read one after the other by repeated INPUT# statements.
The records are separated by commas in the string. Once a record has been read, it
cannot be read again until the file has been closed and then opened again.
This example reads six records in a file and places the data in six variables:
10
OPEN “QFILE” FOR OUTPUT AS #1
20
PRINT #1, “Record A”,“a”,“b”,“c”
30
PRINT #1, “Record B”,1,2,3
40
PRINT #1, “Record C”,“x”;“y”;“z”
50
PRINT #1, “Record D,Record E,Record F”
60
CLOSE #1
70
OPEN “QFILE” FOR INPUT AS #1
80
INPUT #1, A$
90
INPUT #1, B$
100
INPUT #1, C$
110
INPUT #1, D$,E$,F$
120
PRINT A$
130
PRINT B$
140
PRINT C$
150
PRINT D$
160
PRINT E$
170
PRINT F$
180
CLOSE #1
RUN
The printer returns:
Record A a b c
Record B 1 2 3
Record C xyz
Record D
Record E
Record F