Here's an old friend...GOTO lazarus / 8-Other ---------------------------------------------------------------------- minesadorada · 2014-07-30 19:03 There is still a use for GOTO, surely?  I read somewhere that the fpc compiler loves GOTO statements, as they optimise to machine code easily. It's surprising that the current version of Laz/FPC still supports the LABEL and GOTO commands because they have been unfashionable for decades.  I did remember the syntax though.. Quick 'n dirty string input routine using LABEL and GOTO that won't let go until szPW is assigned a non-blank string: Code: [Select]var   iRetries:Integer;   sz,szPw:String; LABEL STARTAGAIN,RETRYPW; begin iRetries:=3; RETRYPW: sz:=''; If iRetries=0 then GOTO STARTAGAIN;   If InputQuery(   Format('Input password.  Tries left %d',[iRetries]),   'Please type in a non-blank passowrd',TRUE, sz) then   szPW:=sz   else // user closed query    begin     Dec(iRetries);     GOTO RETRYPW;    end;   STARTAGAIN: // user cancelled 3 times   iRetries:=3;   If (sz = '') then GOTO RETRYPW; // user entered nothing ShowMessage(szPW); ---------------------------------------------------------------------- marcov · 2014-07-30 19:16 goto is mostly used in lowlevel code. Remember that Free Pascal implements its own RTL in itself. Having goto eliminates some uses for assembler. Also, jumping with goto out multiple nested IFs is usually still faster than without. (afaik both FPC and Delphi have this trait) ---------------------------------------------------------------------- BeniBela · 2014-07-30 20:13 I think you must add COMEFROM to the syntax, too. That can be really nice to write ---------------------------------------------------------------------- minesadorada · 2014-07-30 21:06 Quote from: BeniBela on July 30, 2014, 10:13:44 pmI think you must add COMEFROM to the syntax, too. That can be really nice to write Oh I like that. If there was a statement DidntMeanToGOTO or OOPS it could replace EXCEPT, and be more truthful... Try  ...code.. OOPS ..apology here End; ---------------------------------------------------------------------- Edson · 2014-07-31 02:51 Quote from: minesadorada on July 30, 2014, 11:06:35 pmQuote from: BeniBela on July 30, 2014, 10:13:44 pmI think you must add COMEFROM to the syntax, too. That can be really nice to write Oh I like that. If there was a statement DidntMeanToGOTO or OOPS it could replace EXCEPT, and be more truthful... Try  ...code.. OOPS ..apology here End; Casually, I was looking for new instructions for a language that I'm writing. I will include these . ---------------------------------------------------------------------- skalogryz · 2014-07-31 03:14 Quote from: Edson on July 31, 2014, 04:51:18 amCasually, I was looking for new instructions for a language that I'm writing. I will include these . Lolcode? @minesadorada, you've made a perfect example of how, where and why NOT to use goto.