Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any way to goto a label from inside a WITH DO block?

Status
Not open for further replies.

ProgressingPilgrims

Programmer
Apr 4, 2008
4
0
0
US
Is there a way I can get goto mylabel to work inside the below WITH DO block? After the begin I get the red squiggley line under both mylabel references as it is. If I change the colon to a semi-colon the red squiggley disappears from the second reference to mylable; All the code in this procedure is conveniently within this begin with NTO, coreVars DO section. Hope I can find a way to goto labels within it with much rearrangement.

procedure TTM_MtnSide.calc;
label
mylabel;
begin with NTO, coreVars do
begin
goto mylabel;
//bunch of code lines I want to skip
mylabel:
//more code lines
end
end;
 
Why are you using goto? (Never used it in 20+ years of Pascal programming practice...)

TIA
TonHu
 
procedure TTM_MtnSide.calc;
const
SkipJunk = true; //var SkipJunk: boolean= true;
begin
with NTO, coreVars do begin
if not SkipJunk then begin
//bunch of code lines I want to skip
end else
begin
//more code lines
end
end
end;


Roo
Delphi Rules!
 
Never even seen goto code in Delphi (seen & used it in less rich languages) or Pascal in 15+ years here. Another deprecated programming practice.

----------
Measurement is not management.
 
deprecated?? GOTO was never an accepted pascal programming practice. It has been included since TP as an aid to those converting from BASIC and other spaghetti languages.

Hopefully Pilgrim has figured out that GOTO will raise the hair on the back of any pascal programmer's neck.

Roo
Delphi Rules!
 
deprecated?? GOTO was never an accepted pascal programming practice. It has been included since TP as an aid to those converting from BASIC and other spaghetti languages.

True that it was never an accepted Pascal programming practice, but it was an accepted programming practice nonetheless. Usually when I was in a language that forced you into it, I only tended to use it for things that there are TP/Delphi equivalents for (break, exit), but weren't already included in the language as standard words.

----------
Measurement is not management.
 
Hm, what the OP really needs is a set of (nestable) blockcomment markers, like
Code:
{ }
or
Code:
(* *)

HTH
TonHu

P.s.: Glad I hit the nail on the head ;-)
 
I think we're pretty much in agreement. I too use the occasional break/exit out of necessity. I had a hard time getting my mind around try/except when it was introduced, which is basically a go-to.

Roo
Delphi Rules!
 
Glenn9999 said:
Never even seen goto code in Delphi...
Me neither, until now!

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Yah. Never knew GOTO was in Delphi. Haven't used that since the QBASIC class I took in high school.

~
Chuck Norris is the reason Waldo is hiding.
 
sggaunt said:
Anyway this link seems to confirm that goto has always been in there, but dont use it right!
Uh, no! Goto was never in Wirth's Pascal. Your link just goes to show what happens when a committee (ISO) gets its hands on something.
 
GOTO existed in Turbo Pascal 3.1, it was documented and I used it some of my first transition programs from Fortran to Pascal. Anyway the transition also implied going from going from punch card to ibm-pc compatible without hardrive, only one 180 K floppy.

In sequential-driven programming like in the DOS environment it could be handy if you wanted to obscure the code, but in the event-driven (windows) environment I would not know how to use it.
Anyway I did not know it still existed in Delphi, never used it since I saw the power of repeat - until

Steven
 
I'd very be interested to see anyone write a program that does anything useful without, ultimately, using GoTo or an equivalent. I've never been able to.

[vampire][bat]
 
@Earthandfire

Hello World?

~
Chuck Norris is the reason Waldo is hiding.
 
EWF: Ive never written a program that does anything useful, so I dont know.[smile]



Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
 
Opieo, I'm not sure that I would call "Hello World" particularly useful. Additionally, if you disassemble your Hello World program, I'm sure you will find JMP or similar statements in it.

sggaunt, EWF. I did explain my handle when I was a member of TTUK and stressed that the "W" was not omitted by accident.


Personally, I do not use GoTo in high level languages (and, to be honest have never found the need for it - except in a tongue in cheek answer to a recent post in the VB.NET forum). I just felt that the "attack" on the OP was rather unfair when, in reality it is virtually impossible to program without GoTo. Additionally, if the language vendor provides GoTo, then it is not up to us to put down someone for using it. roo0047 was the only poster here to provide what I consider to be a helpful, constructive and intelligent answer.

[vampire][bat]
 
eartandfire
Sorry that just my speed reading.

When you were a member of TTUK? You know you cannot resign from TTUK, its like the Hotel California.

But getting back on topic I also write embedded 'C', and if at all possible (it isn't always) I avoid embedding assembler, I'm not sure that the presence of JMP's in Assembler is relevant to program design in a high level language. (except for the compiler of course).


Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
 
earthandfire said:
I just felt that the "attack" on the OP was rather unfair...
I don't believe anyone was "attacking" the OP. Some (including my own) responses were expressing surprise at seeing Goto in Delphi and others were warning that Goto is not good programming practice.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top