102{
103
104 endOfPattern = false;
105
106
107 if (inputPos == -1)
108 {
109 inputLine.ReadLine(input);
110 inputPos = 0;
111 }
112
113
114 if (repeatCount == 0)
115 repeatCount = GetIntegerFromFormat();
116
117
118 if (repeatCount == 0)
119 repeatCount = 1;
120
121 int repeatPos = formatPos;
122
123
124 if (format[formatPos] == '(')
125 {
126 formatPos++;
127
128 bracketStack.Push(formatPos);
129 bracketCounter.Push(repeatCount);
130 bracketCount.Push(repeatCount);
131
132 repeatCount = 0;
133
134 return false;
135 }
136
137
138 if (format[formatPos] == 'X')
139 {
140 formatPos++;
141
142
143 RejectWidth('X');
144
145
146 inputPos += repeatCount;
147
148
149 repeatCount = 0;
150
151 FinishField();
152
153 return false;
154 }
155
156
157 if (format[formatPos] == '/')
158 {
159 formatPos++;
160
161
162 RejectWidth('/');
163
164
165 while (repeatCount--)
166 inputLine.ReadLine(input);
167
168 inputPos = 0;
169
170
171 if (format[formatPos] == ',' || format[formatPos] || ')')
172 FinishField();
173
174 return false;
175 }
176
177
178 if (format[formatPos] == 'Q' || format[formatPos] == 'P' || format[formatPos] == 'B')
179 {
180 formatPos++;
181
182 int problemStart = formatPos;
183
184 while (format[formatPos] != ',' && format[formatPos] != ')' && format[formatPos] != '/')
185 formatPos++;
186
187 error("Unsupported pattern in FORMAT statement\n\n"
188 "Statement \"%s\" includes unsupporterd pattern '%s'\n",
189 (const char *) format,
190 (const char *) format.SubStr(problemStart, formatPos - problemStart));
191 }
192
193 if (format[formatPos] == ':')
194 {
195 formatPos++;
196
197 if (format[formatPos] == ',' || format[formatPos] || ')')
198 FinishField();
199
200 repeatCount = 0;
201
202 endOfPattern = true;
203
204 return false;
205 }
206
207
208
209
210 int typeStart = formatPos;
211
212 while (CharacterFollows())
213 formatPos++;
214
215 int typeLen = formatPos - typeStart;
216
217
218 int width = GetIntegerFromFormat();
219
220 if (width == 0)
221 error("Unrecognized FORMAT statement\n\n"
222 "Statement \"%s\" is missing a width specifier for a field of type '%s'\n",
223 (const char *) format, (const char *) format.SubStr(typeStart, typeLen));
224
225
226 if (format[typeStart] == 'T')
227 {
228
229 if (format[typeStart + 1] == 'L')
230 inputPos = width > inputPos ? 0 : inputPos - width;
231
232 else if (format[typeStart + 1] == 'R')
233 inputPos += width;
234
235 else
236 inputPos = width;
237
238 repeatCount--;
239
240 if (repeatCount)
241 formatPos = repeatPos;
242 else
243 FinishField();
244
245 return false;
246 }
247
248
249 field.Copy(inputLine, inputPos, width);
250 field.Trim();
251
252 inputPos += width;
253
254 repeatCount--;
255
256 if (repeatCount)
257 formatPos = repeatPos;
258 else
259 FinishField();
260
261 return true;
262}