Sign in to follow this  
Followers 0
East Coast Cracka

Marking and goto

6 posts in this topic

Hey guys,

Since you were so helpful last time, I have one more question to ask.

I am used to programming with ti-83 calculators and I was wondering if there was any way to mark a spot in a script with a number or a letter or something then go back to it later. What I am trying to accomplish is mark my spot after each while loop in my code. My problem is that the script may encounter something unexpected at any time and I have a loop to take care of it. SO what I want to do is be able to go back to the last part of the script that I know worked by checking the placeholder the using a goto type statement. I am assuming thre is an easy way or a function that will do this that is built in... but i've been unable to find it.

Thanks guys! :">

Share this post


Link to post
Share on other sites



Just create a function that will accomplish waht you need to do and then call the function whenever you are ready to perform those actions. By this I mean, take the code that would normally appear after the goto and put that in a function. When you would use the goto LABEL, instead just call your function.


_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

Just create a function that will accomplish waht you need to do and then call the function whenever you are ready to perform those actions. By this I mean, take the code that would normally appear after the goto and put that in a function. When you would use the goto LABEL, instead just call your function.

I think you have misunderstood what I am trying to do. I am using the goto's to go back into my script. When something unexpected happens it drops down to the end of my script and runs a few while loops to take care of the unexpected happenings. At the end of the loops that takes care of the happenings, i wanted a "Return to $loopmarker" style thing. I would be putting $loopmarker = (something) lines along the way so that there are multiple points to return to.

Any more ideas?

Sorry I am as vague as this is, I haven't written this yet so I don't have specific problems with it yet, I just don't know if there is an equivalent way to do it with AutoIT.

Share this post


Link to post
Share on other sites

I think you have misunderstood what I am trying to do. I am using the goto's to go back into my script. When something unexpected happens it drops down to the end of my script and runs a few while loops to take care of the unexpected happenings. At the end of the loops that takes care of the happenings, i wanted a "Return to $loopmarker" style thing. I would be putting $loopmarker = (something) lines along the way so that there are multiple points to return to.

Any more ideas?

Sorry I am as vague as this is, I haven't written this yet so I don't have specific problems with it yet, I just don't know if there is an equivalent way to do it with AutoIT.

Sub _Main()
ONERR GoTo ERRORHANDLER
' code goes here.


Exit Sub
ERRORHANDLER:
Select Case Err
     Case 5000
         MsgBox "Bombed!", vbokonly, "Error:  " & Err
     Case Else
          MsgBox "Unhandled error, contact developer", vbokonly, "Error:  " & Err
End Select
End Sub

I believe you're writing code similar to the above, but perhaps uses GOSUB, or similar structure.

You're asking for functionality that is not avialble and will not be available in AutoIt v3. Goto was removed because it encourages idiotic programming practices and spaghetti code.

Using a function like a GOSUB <label> is just fine, especially in a large While/WEnd loop....it just takes a bit more thought.

If you MUST have your GOTO/GOSUB ... AutoIt version 2 is still out there...but not NEARLY as useful as version 3 is.

To tell you the honest truth...I've not missed those two commands.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Okay, thank you =)

Looks like I need to find another way to do this. Problem is I am not a real programer, I just moonlight every once and awhile while trying to be brilliant. :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I am using the goto's to go back into my script. When something unexpected happens it drops down to the end of my script and runs a few while loops to take care of the unexpected happenings. At the end of the loops that takes care of the happenings, i wanted a "Return to $loopmarker" style thing.

This is exactly what is possible through the use of function calls.

Lets say this is my sample program:

Dim $a

While 1
    $a = 1 + 1
    
    if $a == 2 Then
        ;perform expected actions here or jsut keep looping
    Else
        ;call the function to handle the unexpected results
        unexpected()
    EndIf
WEnd

Func unexpected()
    $a = 2
EndFunc

While the above example is extremely simple it proves that what you are trying to do is possible through functions and that goto's are not needed.

EDIT: P.S. this is an infinite loop, dont run this it is merely written to prove a point

Edited by Don N

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

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