Jump to content
Sign in to follow this  
MeisterMan

returning to specific loop/variable/point to make the main GUI loop work after exiting another look in function

Recommended Posts

MeisterMan

i searched and googled for 2nd day today got sick of doing it cant find the answer. :(

 

but my problem is ... when i click stop the loop stops... but adlib doesnt work anymore... i have to click X  for it start running again afterwards ... but if ill stop again then it will exit the whole thing.

guicreate("")

$runbutton = guictrlcreatebutton("")
guictrlsetoevent($runbutton, "_run")
$stopbutton = guictrlcreatebutton("")
guictrlsetonevent($stopbutton, "_stop")

guisetstate()

adlibregister("_something", 2000) ; this isnt working after you click a button to exit the _something() loop ...

while 1
;do anything here 
$return_point
wend

func _run()
$switch = 1
$go = 1
;then adlib will call the func and because $switch is 1.. the loop will run...
endfunc

func _stop()
$go = 0 ;set this to 0 on button click to end the looping... 
$switch = 0
endfunc

func _something()

while $switch = 1
$switch = 0 ; this will set $switch off so this While loop isnt in constant looping mode.
;do other things here when this func is called 

;somewhere in the middle of the code we put this
if $go = 0 then exitloop ; and this is where i want to return  to $return_point variable... return $return_variable didnt seem to work for me.. ? 

;and also only enter this loop if $switch is set to 1 by pressing a button on main gui...
wend
if $go = 0 then $switch = 0
endfunc 
Edited by MeisterMan

Share this post


Link to post
Share on other sites
Melba23

MeisterMan,

Sorry, that collection of apparently random lines makes no sense to me at all. Why not explain what it is that you want to happen in your script and then we can try to develop something coherent that works. :)

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

 

Share this post


Link to post
Share on other sites
MeisterMan

*updated better.... sorry

Share this post


Link to post
Share on other sites
Melba23

MeisterMan,

Firstly, if you spend more than 2 secs in your _something function than you are in big trouble. You will still be in the function when it is called again - and queuing Adlib functions is a recipe for disaster. :(

If you think you might be doing this, you need to UnRegister the Adlib function as you enter it and then re-Register it as you leave. ;)

Secondly, breaking into a running function is not easy in AutoIt - see the Interrupting a running function tutorial in the Wiki to see how you might go about it. :)

But I return to my earlier point - please explain exactly what it is you want to do so that we can come up with the most sensible way of coding it for you. Just trying to get your current minimalist script to work will almost certainly not provide you with the correct method for what you actually want to do. ;)

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

 

Share this post


Link to post
Share on other sites
MeisterMan

ok so i should unRegister adlib inside the _something() function ? 

yeah i read the "interupting a running function" its about guionevent which is why i put the 2 buttons with guictrlsetonevent() :) 

 

with returning thing though ... what i want to do is like ..

say we have 2 loops... 

while 1

;do some main and most importants things .... or w.e.
$return

wend



;now we have a function with a while loop inside it 
;like i posted above in the fiirst post

func _something()
while 1

return $return ; but i know that "Return" does not go to the specific point like in this case go to $return and 
;continue looping inside the first while loop...
wend
endfunc

Share this post


Link to post
Share on other sites
Melba23

MeisterMan,

 

i read the "interupting a running function" its about guionevent

No it is not. It shows that both GUI modes suffer from the same problem and require the same solutions, although there is a possible shortcut if you use OnEvent in a specific way - which you are not doing here. :(

So for the last time, please explain what it is that you want to do in this script rather than continue to post useless snippets of pseudo-code which mean absolutely nothing. If you want help then tell us the purpose of this script - otherwise there is no point in continuing. Your choice. :)

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

 

Share this post


Link to post
Share on other sites
MeisterMan

:D grrr i dont know how to explain better.... 

i want to return from second while loop to first while loop 

so basicly stop second loop and go back into first loop.

make sense? :( 

Share this post


Link to post
Share on other sites
Melba23

MeisterMan,

OK, I am out of this thread. With no idea of what these loops do, what kind of code is in them, or any idea of the overall aim of the script I am not wasting my time writing code which may or may not fit the bill. :bye:

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

 

Share this post


Link to post
Share on other sites
MeisterMan

the loops dont do anything... they do whatever .. they are just loops :D 

but i just dont know how to go back to first loop and continue looping in the first while loop

Share this post


Link to post
Share on other sites
MeisterMan

i kept looking at forums and found simple solution. not 100% effective but works 90% ild say :D

and the answer is .. for anyone else that will need in future ...

while 1 ;main gui while loop....
if $on = 1 then ;you change the variable value with a button or whatever.....
      while $on = 1 ;your whatever thing loop here...
          ;do things here...
          ;if you would want to exit loop while processing it through with loads of things just put this..
          exitloop 
          ;if you have more than one or two loops then for example...
          while $set = 1
                ;do something here then ...
                while $go = 1
                      ;do something here and exit 
                      if $on = 0 then exitloop 3 ;this will exit all loops and go into the first gui loop to continue showing main gui....
                wend
           wend
     wend
endif
;exitloop [3] will go here automatically... :P
wend

those who will really need such thing will understand... :D

Edited by MeisterMan
  • Like 1

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  

×