Jump to content

Jump back into a cae where left off.


Gotemp
 Share

Recommended Posts

Is it possible to jump back into a case where you left off? I'll post some demo code with what i mean and i keep having ideas on how to do it but so far they have failed, even re-wrote the damn thing which took me a good 30mins and then... it failed! Anyway here is an example i just wrote because i dont know if im doing it right or if there is a better way, plus its getting late.

Sorry its not indented or anything, the autoit code button always fails to work properly. -.-

Global $action = 1
Global $action1 = 3
Global $action2 = 2

Func Test()
Do
Select
Case $action = 1
Select
Case $action1 = 1
Check()
;code for action1
Case $action1 = 2
Check()
;code for action2
Case $action1 = 3
Check()
;code for action3
EndSelect
Case $action = 2
Select
Case $action2 = 1
Check()
;code for action1
Case $action2 = 2
Check()
;code for action2
Case $action2 = 3
Check()
;code for action3
EndSelect
EndSelect
Until $action > 4
Exit
EndFunc

Func Check()
;imageseach code here
if $image = 1 then
;image exsists it shouldnt so re-run code
Check()
ElseIf $image = 0 Then
;image does not exsist this is good continue
;where $action1,$action2 or $action3 left off
EndIf
EndFunc
Link to comment
Share on other sites

  • Moderators

Gotemp,

Your Check() function is not well written - you are making it infinitely recursive. Read the Recursion tutorial in the Wiki to see why this is not a good idea. ;)

I would rewrite it something like this: ;)

Func Check()
    Local $image = 1
    While $image = 1
        ;imageseach code here
    Wend
    ; We get here if Image = 0
        ;image does not exsist this is good continue
        ;where $action1,$action2 or $action3 left off
    ; And so we now return
EndFunc   ;==>Check

Now what exactly do you want to do when you return from this function? If all you want to do is run the next case you should look at ContinueCase. Or do you want to rerun the whole Select structure again? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks Melba will read up on recursion, i normally use a loop and sleep command but i wrote this code right before bed when i was very tired and im still tired now i got up!

But here is what i mean The code is a loop of 5 Paretns, within them 5 Parents are the children which is the code that the user picks for example if the user picks child3 > Check runs = 0 Continue with child3 code once thats complete goto the next parent and child action so in the code below we need to do all the code in Parent1 > Child3 before we move onto Parent2 > Child1 So its Parent > Child3 > Check > Child3 > Parent2 > Child1 > Check > Chld1 > Parent3 if that makes sense guess not because im confused o.O lol

$parent = 1
$child1 = 3
$child2 = 1

Func Test()
Do
Select
Case $parent = 1
Select
Case $child1 = 1
Check()
;code for action1
$parent = $parent + 1
Case $child1 = 2
Check()
;code for action2
$parent = $parent + 1
Case $child1 = 3
Check()
;code for action3
$parent = $parent + 1
EndSelect
Case $parent = 2
Select
Case $child2 = 1
Check()
;code for action1
$parent = $parent + 1
Case $child2 = 2
Check()
;code for action2
$parent = $parent + 1
Case $child2 = 3
Check()
;code for action3
$parent = $parent + 1
EndSelect
EndSelect
Until $parent > 4
Exit
EndFunc

Also which browser is beter for the autoit code? Im using chrome and its always indented to the left like above makes it hard to read imo :/ anyawy better get ready off out for the day.

Edited by Gotemp
Link to comment
Share on other sites

  • Moderators

Gotemp,

if that makes sense guess not because im confused

And so am I. :wacko:

If you want some help, please explain clearly what it is you are trying to do. At the moment I cannot really work out the logic behind your request and I am not prepared to code several possible solutions on the off-chance that one meet your requirements. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...