Sign in to follow this  
Followers 0

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

5 posts in this topic

#1 ·  Posted

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:

:mylabel

...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...

Wend

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:

:mylabel

...do something...

...and something else...

goto, :helpme

:helpme

...do something...

...and something else...

goto, :please

: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...

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted

reecedorward,

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.

Realm


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.  

Share this post


Link to post
Share on other sites

#3 ·  Posted

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?

Cheers,

Reece

Share this post


Link to post
Share on other sites

#4 ·  Posted

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


- Bruce [font="'Lucida Console';"]/*somdcomputerguy */  If you change the way you look at things, the things you look at change.[/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted

reecedorward,

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.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0