On Fri, 28 Nov 2003, Anton Tichawa wrote: > function scanblack(var s: string): string; > var > i: integer; > begin > i := 1; > repeat > if i > length(s) then begin > break; > end; > if s[i] = ' ' then begin > break; > end; > inc(i); > until false; > result := copy(s, 1, i - 1); > delete(s, 1, i - 1); > end;
When I compiled the code, I got "identifier not found result", so I added "result: string;", but even though it then compiles, the function returns garbage (not "49ers" in the first instance). The original line gets read in correctly ("49ers at Giants 16 13"), so the problem is after that. Should there be a line along the lines of "return result" in the function? I haven't really used functions much (at least not any that returned anything anyway). This code helps me to understand a bit more (at least when I get time to sit down and look at it some more anyhow) - the above is a different approach to anything I've used before (having not used strings before), so I wouldn't have thought of it myself. > if scanblack(line) <> 'at' then begin > writeln('syntax error'); I'm getting this coming up, presumably because the functions aren't quite working. thanks, dp. _______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal