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

Reading a Specific Data Length With INPUT$, Reading a Line to a Variable With LINE INPUT

Page 58 highlights

Chapter 4 - Managing Input and Output Reading a Specific Data Length With INPUT$ INPUT$ reads a specified number of characters from the specified sequential file or channel. By default, if no file or channel is specified, the data on the standard IN channel is read. The execution is held up waiting for the specified number of characters to be received. If a file does not contain as many characters as specified in the INPUT$ statement, the execution resumes as soon as all available characters in the file have been received. Sequential files are read from the start and once a number of characters has been read, they cannot be read again until the file is closed and opened again. Subsequent INPUT$ statements start with the first of the remaining available characters. Example (reads portions of characters from a file OPENed as #1): 10 OPEN "QFILE" FOR OUTPUT AS #1 20 PRINT #1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 30 CLOSE #1 40 OPEN "QFILE" FOR INPUT AS #1 50 A$=INPUT$(10,1) 60 B$=INPUT$(5,1) 70 C$=INPUT$(100,1) 80 PRINT "Record 1:",A$ 90 PRINT "Record 2:",B$ 100 PRINT "Record 3:",C$ 110 CLOSE #1 RUN The printer returns: Record1: ABCDEFGHIJ Record2: KLMNO Record3: PQRTSUVWXYZ Reading a Line to a Variable With LINE INPUT# This command reads an entire line (including all punctuation) to a string variable. Commas inside a string are treated as punctuation marks and do not divide the string into records. This example reads a complete line in a file and places the data in a "single-string" variable): 10 OPEN "QFILE" FOR OUTPUT AS #1 20 PRINT #1, "Record A,Record B,Record C" 30 CLOSE #1 40 OPEN "QFILE" FOR INPUT AS #1 50 LINE INPUT #1, A$ 60 PRINT A$ 70 CLOSE #1 RUN The printer returns: Record A,Record B,Record C 46 Fingerprint Developer's Guide

  • 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
46
Fingerprint Developer’s Guide
Reading a Specific Data Length With INPUT$
INPUT$ reads a specified number of characters from the specified sequential file or
channel. By default, if no file or channel is specified, the data on the standard IN
channel is read.
The execution is held up waiting for the specified number of characters to be
received. If a file does not contain as many characters as specified in the INPUT$
statement, the execution resumes as soon as all available characters in the file have
been received.
Sequential files are read from the start and once a number of characters has been
read, they cannot be read again until the file is closed and opened again. Subsequent
INPUT$ statements start with the first of the remaining available characters.
Example (reads portions of characters from a file OPENed as #1):
10
OPEN “QFILE” FOR OUTPUT AS #1
20
PRINT #1, “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
30
CLOSE #1
40
OPEN “QFILE” FOR INPUT AS #1
50
A$=INPUT$(10,1)
60
B$=INPUT$(5,1)
70
C$=INPUT$(100,1)
80
PRINT “Record 1:”,A$
90
PRINT “Record 2:”,B$
100
PRINT “Record 3:”,C$
110
CLOSE #1
RUN
The printer returns:
Record1: ABCDEFGHIJ
Record2: KLMNO
Record3: PQRTSUVWXYZ
Reading a Line to a Variable With LINE INPUT#
This command reads an entire line (including all punctuation) to a string variable.
Commas inside a string are treated as punctuation marks and do not divide the
string into records.
This example reads a complete line in a file and places the data in a “single-string”
variable):
10
OPEN “QFILE” FOR OUTPUT AS #1
20
PRINT #1, “Record A,Record B,Record C”
30
CLOSE #1
40
OPEN “QFILE” FOR INPUT AS #1
50
LINE INPUT #1, A$
60
PRINT A$
70
CLOSE #1
RUN
The printer returns:
Record A,Record B,Record C