label used before containing beinding
Tom Verhoeff
wstomv at win.tue.nl
Tue Feb 3 08:44:01 CET 2004
>Nick Ioffe wrote:
>
>> I've encountered the message in the subject trying to compile
>> the following:
>>
>> program x(input, output);
>> label
>> x_label;
>> var
>> z:integer;
>> w:string;
>> function f:string
>> begin
>> f:='f';
>> end;
>>
>> begin
>> if z = 1
>> then
>> begin
>> writeln('to x_label');
>> goto x_label;
>> end;
>>
>> w:= 'z:'+f;
>>
>> x_label:;
>>
>> end.
>>
>> Compilation fails and I get:
>> x.pas:3: label 'x_label' used before containing binding contour.
Have you tried it with numeric labels (which at least the original
Pascal definition required)?
program ...;
label 99;
begin
...
... goto 99
...
99:
end.
An alternative is to put the code in a separate procedure, and use Exit
to leave it early. Exit is basically a jump to the end of the
procedure. You can also use Exit in the main program to terminate
execution (jump to the end). See documentation for details on Exit.
Tom
More information about the Gpc
mailing list