: This message was edited by Opius at 2003-2-24 16:15:50
: : I know you can use Labels in Basic, and I think C++, but can you use them in pascal?
: : In basic, you would use:
: : LabelX:
: : //code
: : if a = 5 then
: : GOTO LabelX;
: : end
: : If there are labels (Surely there are, right?) how would you use them?
: Labels/Goto statements are an integral part of spaghetti code. Fortunately (or unfortunately), there are no label/gotos in any strutctured programming language such as C++ or Pascal, at least as far as I know. An easy way to do this sort of thing is to use procedures and functions. Example
Personally I havent ever used GOTO, but like everything there is a time and place for it. And Pascal does support it. Here is an example (written from memory, it may not be syntactically correct)
while (1=1) do
Ch := ReadKey;
if (Ch = #27) then
WriteLn('Used GOTO to exit the loop');