Jump to content


Help with "While"... the new 'goto'

  • Please log in to reply
4 replies to this topic

#1 reecedorward



  • Active Members
  • 27 posts

Posted 28 April 2012 - 01:35 AM

I read this in the FAQ about the old 'goto' function...

Just to get you started, the most basic use of Goto in version 2.64 was an infinite loop like:
...do something...
...and something else...
goto, mylabel

A simple v3 version of that is a While loop that is always "true".
While 1 = 1
...do something...
...do something else...

That above makes sense... but I do believe with the goto function you would be able to tell the script to 'goto another section' of the script, where as the while 1 = 1 loop will only loop whats within 'While' and 'Wend'...

with the old 'goto' function (i never used it) but im guessing you'd be able to acheive something similar to this:
...do something...
...and something else...
goto, :helpme

...do something...
...and something else...
goto, :please

...do something...
...and do something else...
goto, :helpme

Instead of looping from ":mylabel" to ":mylabel" like the example in the FAQ section... the script above actually tells the script to go from one loop to another loop... I want to know how to do this with the "While" function

I have read all through the Functions help file for anything relative towards what im in search of, but i cant find anything... I'm hoping that an expert on here can explain to me how to do the following without directing me back to the help file on the account of I'm totally new at this and have no idea...


#2 Realm


    Lives in a tiny bubble

  • Active Members
  • PipPipPipPipPipPip
  • 652 posts

Posted 28 April 2012 - 02:40 AM


Why not create a custom function like:
Func _MyGoToFunction()     ;Do my Goto needs here EndFunc

Then whenever you need to call that portion of your script all you have to do is call it like so:
If $Do_I_need_ToGo Then _MyGoToFunction()

It's actually better than a GoTo call as old school programming used, since it runs the portion of needed script, then returns back to where it left off before.


My Contributions:
Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time.
RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.


#3 reecedorward



  • Active Members
  • 27 posts

Posted 28 April 2012 - 02:53 AM

AH HA! Thanks Realm

That has helped a lot! I will give that a go and post the results in here when its done ;)

Also, with the line Func _MyGoToFunction () ..... what are the end brackets for?



#4 somdcomputerguy


  • Active Members
  • PipPipPipPipPipPip
  • 2,869 posts

Posted 28 April 2012 - 03:31 AM

It's explained nicely in the Help file - Language Reference - User Functions ;)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

#5 jchd


    Resistance is obligatory.

  • MVPs
  • 5,530 posts

Posted 28 April 2012 - 04:13 AM

Remove the useless labels and gotos in your last example and you're left with a simple sequence of instructions, since there is no loop in your pseudo-code.

OTOH, what guys are suggesting is bad. A much better idea is to restructure the code to blocks and true functions.

SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!

SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)

An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.


SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.


PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

RegExp tutorial: enough to get started

Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users