[fpc-pascal]opening files from a text list

Marco van de Voort marcov at stack.nl
Fri Nov 28 05:19:23 CET 2003


> 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;",

Either you have to compile in Delphi modes (-Sd or -S2), or replace result:=
by scanblack:=

> returns garbage (not "49ers" in the first instance).

That's because result is the name of the return value in Delphi, while it
is the name of the function in TP.

By defining a result variable yourself, the return value gets lost.




More information about the fpc-pascal mailing list