Jump to content

func continue of where it left


Recommended Posts

im wondering how to make like

u have func and it calls other func ,but when it calls bk to first one.. it wont call it at start of first pixel search.. it will continue the Func 1() at where it left off for example at second pixel search it called 6 and func 6() called bk to func 1() and so func 1() will continue form last pixelsearch.. if u gett me

example:

Func 1()
While 1
searchpixel("............")
if not @eror then
send("...")
Call("5")

searchpixel("............")
if not @eror then
send("...")
Call("6")

searchpixel("............")
if not @eror then
send("...")
Call("7")
EndFunc

Func 5()
send("..")
[color="#FF0000"]Call("1") ;but how to make it continue the func1 at where it left of there?[/color]
endfunc

func 6()
send("")
[color="#FF0000"]Call("1") ;but how to make it continue the func1 at where it left of there?[/color]
endfunc

func 7()
send("")
[color="#FF0000"]Call("1") ;but how to make it continue the func1 at where it left of there?[/color]
endfunc
Edited by TomaSzz
Link to comment
Share on other sites

hmm not rly.. i mean like... when Func 1() will call func 5() from middle of Func 1() .. func5 will do its job ,but when func 5() will call bk to Func 1() ..func 1() wont start from begining,but continue from it left off at last call... get me now?

Link to comment
Share on other sites

Aah, ok. Uhm...

Mayby this could be useful?

MyFunc1(1)

Func MyFunc1($Value)
    If $Value < 5 Then
        MsgBox(64, "", "Value is still smaller as 5! [" & $Value & "]")
        MyFunc2($Value)
    Else
        MsgBox(64, "", "Value equals to 5! [" & $Value & "]")
        Exit
    EndIf
EndFunc

Func MyFunc2($Value)
    $Value += 1
    MyFunc1($Value)
EndFunc

:mellow:

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Aah, ok. Uhm...

Mayby this could be useful?

MyFunc1(1)

Func MyFunc1($Value)
    If $Value < 5 Then
        MsgBox(64, "", "Value is still smaller as 5! [" & $Value & "]")
        MyFunc2($Value)
    Else
        MsgBox(64, "", "Value equals to 5! [" & $Value & "]")
        Exit
    EndIf
EndFunc

Func MyFunc2($Value)
    $Value += 1
    MyFunc1($Value)
EndFunc

:mellow:

i totaly dont get this script :P maybe in simpler way? :party:
Link to comment
Share on other sites

would this return work for like

3Funcs?

like this:

Func 1()

something here....

Call("2")

EndFunc

func 2()

sumtin here...

Call("3")

endfunc

Func 3()

sumtin here..

and return to first func to where it left off...

endfunc

Link to comment
Share on other sites

  • Moderators

TomaSzz,

You are getting yourself and us very confused here. :party:

Look at this short script - when you run it you return to Func _1 and continue the function where you left off:

_1()

Func _1()
    ConsoleWrite("Starting 1" & @CRLF)
    _2()
    ConsoleWrite("Continuing 1" & @CRLF)
    Return
EndFunc

Func _2()
    ConsoleWrite("Starting 2" & @CRLF)
    _3()
    Return
EndFunc

Func _3()
    ConsoleWrite("Starting 3" & @CRLF)
    Return
EndFunc

The Return commands are not really necessary, but they do not harm. Note you do not need Call - you just use the function name. :P

Does that make it clearer? :mellow:

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

ok but...as far as i understand return function returns u to previous func? dont it?

and waat i want to make is like 3rd func to call 1st func but not start the 1st func from beginning,just keep going as where it finished

Link to comment
Share on other sites

Just realized i understood you wrong.

_1()

Func _1()
    ConsoleWrite("Starting 1" & @CRLF)
    _2()
    ConsoleWrite("Continuing 1" & @CRLF)
    Return
EndFunc

Func _2()
    ConsoleWrite("Starting 2" & @CRLF)
    _3()
    Return
EndFunc

Func _3()
    ConsoleWrite("Starting 3" & @CRLF)
    Return
EndFunc

look at this code from Melba. What happens is

call function 1

print starting 1

call function 2

print starting 2

call function 3

print starting 3

return to where function 2 was

return to where function 1 was

print continuing

return at the point where function 1 was called (in this program it means no code left to be executed)

hope this info helps. try to read the code and my text with it.

Edited by cageman
Link to comment
Share on other sites

  • Moderators

TomaSzz,

Have you run the code?

What is happening within it is as follows:

- Start Func _1

- Interrrupt Func _1 to run Func _2

- Start Func _2

- Func _2 now runs Func _3

- Start Func _3

- End Func _3 which returns you to the calling point in Func _2

- End Func _2 (because there is nothing left to run) and return to the calling point in Func _1

- Continue running Func _1 until it ends.

That is what you said you wanted to happen. :mellow:

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

No hard feelings, but do you understand what we are saying?

_1()

Func _1()
    ConsoleWrite("Starting 1" & @CRLF)
    _2()
    ConsoleWrite("Continuing 1" & @CRLF)
    Return
EndFunc

Func _2()
    ConsoleWrite("Starting 2" & @CRLF)
    _3()
    Return
EndFunc

Func _3()
    ConsoleWrite("Starting 3" & @CRLF)
    _1()
    Return
EndFunc

this would create an endless loop that would go through the functions like: 1 --> 2 --> 3 --> 1 --> 2 --> 3.. you really want this?

lets hope it helps

ye now i get it :mellow: so i just add like in my script i got Func 1() and Func 3() so if i just add at func 3 that

Func 3()
some stuff of my own here with Send and sleep lines..
_1()
Return
endfunc

this would do huh? :party:

TomaSzz,

Have you run the code?

What is happening within it is as follows:

- Start Func _1

- Interrrupt Func _1 to run Func _2

- Start Func _2

- Func _2 now runs Func _3

- Start Func _3

- End Func _3 which returns you to the calling point in Func _2

- End Func _2 (because there is nothing left to run) and return to the calling point in Func _1

- Continue running Func _1 until it ends.

That is what you said you wanted to happen. :party:

M23

ye but ur second func has nothing in it... and mine does :P:party:
Link to comment
Share on other sites

  • Moderators

TomaSzz,

ye now i get it

No you do not!. If you call Func _1 again from within Func _3 you will get into an infinite recursive loop and crash. :P

ur second func has nothing in it... and mine does

And here is a way to get over that: :mellow:

_1()

Func _1()
    ConsoleWrite("Starting 1" & @CRLF)
    _2()
    ConsoleWrite("Continuing 1" & @CRLF)
EndFunc

Func _2()
    ConsoleWrite("Starting 2" & @CRLF)
    If _3() = 1 Then
        Return
    Else
        ConsoleWrite("Continuing 2" & @CRLF)
    EndIf
EndFunc

Func _3()
    ConsoleWrite("Starting 3" & @CRLF)

    Return 1
EndFunc

Now you miss the rest of Func _2 when you return from Func _3 - unless you do not want to, of course, when you use Return 0.

Are we getting closer? :party:

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

ok so what this now does is...it will do func 1 then func 2 then func3 and return to func 1 by going to func 2 and skipping it?

and why there is _2() in func 1 after second console write?

Edited by TomaSzz
Link to comment
Share on other sites

  • Moderators

TomaSzz,

Yes. You can decide within Func _3 whether to skip the rest of Func _2 or not - it all depends on the Return value. :mellow:

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

Func 11()
        $coord = PixelSearch(383, 6, 496, 19, 0x6F0000, 4)
        If Not @error Then
        Call("1")
        Else
        Target()
        Return
        EndIf
EndFunc

where would i put this part then?

If _3() = 1 Then

Return

Else

here?

Func 11()
        $coord = PixelSearch(383, 6, 496, 19, 0x6F0000, 4)
        If Not @error Then
If _3() = 1 Then
        Return
    Else
        Call("1")
        Else
        Target()
        Return
        EndIf
EndFunc

ow wait ..i think its like this aint it?

Func 11()
        $coord = PixelSearch(383, 6, 496, 19, 0x6F0000, 4)
        If Not @error Then
        Call("1")
        Else
        Target()
        Return
        EndIf
                If _3() = 1 Then
                Return
                Else
                EndIf
EndFunc
Edited by TomaSzz
Link to comment
Share on other sites

  • Moderators

TomaSzz,

Where did Func 11 come from? :P How can we help you if you keep introducing new segments of you script? I cannot possibly tell you where to put anything in those few lines.

My young friend, if you need 11 nested functions to do what you are trying to do, you are almost certainly going about it the wrong way. :mellow: Why not try to write down what you want to do so you can get a logic flow - rather like the one I used a few posts above? Having one of those makes coding a lot easier. :party:

So try and explain what you want to do. Use small phrases (as I did) and take great care when you get to If lines. I know you want to code NOW - but you will only get real spaghetti code which you will never debug unless you get it straight in your head what you actually want the code to do.

Over to you - take your time, it is the only way. Once you have it straight, we can help you code it properly. :party:

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