Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Label declared and referenced, but not set

45 views
Skip to first unread message

Francis Burton

unread,
Jun 2, 2009, 12:54:03 PM6/2/09
to
Could someone please tell me what this Delphi error message
actually means? It was displayed when I tried to use a label
and multiple gotos in an ordinary function (not class member
function). I need to execute some state-restoring code and
exit a procedure if any of several operations fail. I think
I am using the correct syntax, as per the help file example,
so I am flummoxed.

(I tried to seek the answer using Google and got mostly pages
in Chinese.)

If I can't get goto to work, I will use exceptions.

Thanks in advance.

Francis

Hans-Peter Diettrich

unread,
Jun 2, 2009, 3:48:15 PM6/2/09
to
Francis Burton schrieb:

> Could someone please tell me what this Delphi error message
> actually means?

IMO you missed to define the label (lbl:) somewhere in the subroutine.

DoDi

Rudy Velthuis

unread,
Jun 2, 2009, 4:19:06 PM6/2/09
to
Francis Burton wrote:

> Could someone please tell me what this Delphi error message
> actually means?

Well apparently, you declared it, and referenced it, but you didn't set
it.

Declare:

label x123;

Reference:

// code
goto x123;
// more code;

Set:

// code
x123:
// code you want to jump to

--
Rudy Velthuis http://rvelthuis.de

"I am become death, shatterer of worlds."
-- Robert J. Oppenheimer (1904-1967) (citing from the
Bhagavad Gita, after witnessing the world's first nuclear
explosion)

Francis Burton

unread,
Jun 2, 2009, 4:59:47 PM6/2/09
to
In article <xn0gaxxlv...@news.online.de>,

Rudy Velthuis <newsg...@rvelthuis.de> wrote:
>Well apparently, you declared it, and referenced it, but you didn't set
>it.
>[...]

>Set:
>
> // code
> x123:
> // code you want to jump to

But I most certainly did! How odd!

I will try and isolate the problem by deleted intervening code
until it works.. or doesn't. I really want to get to the bottom
of this.

Francis

Rudy Velthuis

unread,
Jun 2, 2009, 8:36:25 PM6/2/09
to
Francis Burton wrote:

> > Well apparently, you declared it, and referenced it, but you didn't
> > set it.
> > [...]
> > Set:
> >
> > // code
> > x123:
> > // code you want to jump to
>
> But I most certainly did! How odd!
>
> I will try and isolate the problem by deleted intervening code
> until it works.. or doesn't. I really want to get to the bottom
> of this.

Is the label in the same procedure or function? It MUST be.

--
Rudy Velthuis http://rvelthuis.de

"One word sums up probably the responsibility of any Governor,
and that one word is 'to be prepared'." -- George W. Bush

Francis Burton

unread,
Jun 3, 2009, 2:01:00 PM6/3/09
to
In article <xn0gaygzw...@news.online.de>,

Rudy Velthuis <newsg...@rvelthuis.de> wrote:
>> But I most certainly did! How odd!
>>
>> I will try and isolate the problem by deleted intervening code
>> until it works.. or doesn't. I really want to get to the bottom
>> of this.
>
>Is the label in the same procedure or function? It MUST be.

I thought it was, but I was mistaken. In converting multiple instances
of:

if SomethingWentWrong then begin
TidyUp;
Exit;
end;

into

if SomethingWentWrong then
goto ErrorExit;

I left an 'end' statement in by mistake - so the compiler thought
the function had finished without the label being set. Mea culpa.

Of course, I should have heeded the messages *after* the first one.
I saw them but thought they referred to other errors and warnings
that I had half-expected to encounter.

Mismatched begin/end pairs do happen inadvertently, but usually I
spot them immediately. Not this time. :-/

This has got me wondering whether some form of function highlighting
might be a useful option in the editor - e.g. shading the background
subtly to indicate the extent of a function or procedure, or where
the compiler thinks they end. I guess a folding editor could do that
fairly naturally.

Anyway, sorry to have wasted your time on a trivial matter.

Francis

Rudy Velthuis

unread,
Jun 3, 2009, 2:06:14 PM6/3/09
to
Francis Burton wrote:

> Anyway, sorry to have wasted your time on a trivial matter.

Most errors or mistakes are because of trivial matters, so that is OK.

--
Rudy Velthuis http://rvelthuis.de

"UNIX is basically a simple operating system, but you have to be
a genius to understand the simplicity." -- Dennis Ritchie.

0 new messages