Jump to content

How to stop\break Func immediately.


Recommended Posts

hi2all

simple example what i'm asking about, no real functions and others:

Global $checker = 1

Func make_one_one ()
    
    if $checker Then
        ; here break\stop for general ()
    endif
    
EndFunc

Func make_one ()
    MsgBox (0, "one", "text one")
    
    make_one_one ()
    
EndFunc

Func general ()
    make_one ()
    
;many other functions

    general ()
    
EndFunc

and question:

How to immediately break\stop general () from function make_one_one ()?

Edited by sergeyWolf

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

Link to comment
Share on other sites

that syntaxis will leave you to a crash in the application, read about Recursion

mmmh also General() is not runing make_one_one() the function make_one() run make_one_one()

You can add a statement If to check some condition and aply an action if the condition is true or false, for esample if is true, then run ]make_one_one() if not continueloop.

because the recursion i cant do that, you should use exitloop $n, but i dont know if it work in recursive functions...

Make an statement in general too and check some variable and use return

Is a recursive function what you want? Or is an error doing that way?

Is soo confusing working whitout a working script... :)

Edited by monoscout999
Link to comment
Share on other sites

that syntaxis will leave you to a crash in the application, read about Recursion

mmmh also General() is not runing make_one_one() the function make_one() run make_one_one()

You can add a statement If to check some condition and aply an action if the condition is true or false, for esample if is true, then run ]make_one_one() if not continueloop.

because the recursion i cant do that, you should use exitloop $n, but i dont know if it work in recursive functions...

Make an statement in general too and check some variable and use return

mmm... copy-paste not working? lol, missed "()" at first string of general function (code already edited)

Is a recursive function what you want? Or is an error doing that way?

Is soo confusing working whitout a working script... :)

need something like exit\exitloop fo a Func

or exit\stop currently launched functions (without exiting of GUI and programm in general)

if i'll make statement which will check every time - it would be too ***cking big space of code (i'd wish they make OOP in autoit =\)

recursion not working? mmm... really? it's work fine for me

Edited by sergeyWolf

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

Link to comment
Share on other sites

  • Developers

recursion not working? mmm... really? it's work fine for me

Your posted example will cause a stack overflow after a while as it never ends General properly, assuming that Func will be called at some point in time. Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

if i'll make statement which will check every time - it would be too ***cking big space of code (i'd wish they make OOP in autoit =\)

I try to avoid it

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

Link to comment
Share on other sites

Coding procedure aside; Assigning a hotkey to an exit function will break out of you recursion and exit.

how? example pls, i know how to make pause of script but then it will start from the place of pause

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

Link to comment
Share on other sites

  • Developers

You can only exit the program with an Hotkey without any other logic.

Else the hotkey can call a func that sets a Variable and you need to have a test in the func running to see if its value changed and exit when it does.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Very very basic example of a pause function.

HotKeySet("{PAUSE}","_Pause")

$pause = False

While 1
    ConsoleWrite("Not Paused" & @CRLF)
    Sleep(1000)
WEnd

Func _Pause()
    $pause = Not $Pause
    While $Pause
        Sleep(100)
    WEnd
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

You can only exit the program with an Hotkey without any other logic.

Else the hotkey can call a func that sets a Variable and you need to have a test in the func running to see if its value changed and exit when it does.

so you propose this?
Global $checker = 0


HotKeySet("+!p", "break_all")   

Func break_all ()
    $checker = Not $checker
EndFunc

Func make_one_one ()
    
    If $checker Then
        ; some others
    EndIf
    
EndFunc

Func make_one ()
    
    If $checker Then
        MsgBox (0, "one", "text one")
    EndIf
    
    If $checker Then
        make_one_one ()
    EndIf
    
EndFunc


Func general ()
    
    If $checker Then
        make_one ()
    EndIf
    
    If $checker Then    
        general ()
    EndIf
    
EndFunc
Edited by sergeyWolf

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

Link to comment
Share on other sites

  • Developers

Very very basic example of a pause function.

This doesn't trigger the running Func to end and return which I believe the OP wants. :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

so you propose this?[autoit]

Your examples don't do anything as it doesn't call any func and thus terminate immediately.

Create some running snippet that we can look at and help you with.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Your examples don't do anything as it doesn't call any func and thus terminate immediately.

Create some running snippet that we can look at and help you with.

Jos

ok, working script, untill shift+alt+p not pressed - will run MsgBox

Global $checker = 1


HotKeySet("+!p", "break_all")   

Func break_all ()
    $checker = Not $checker
EndFunc

Func make_one_one ()
    
    If $checker Then
        MsgBox (0, "one one", "text one one")
    EndIf
    
EndFunc

Func make_one ()
    
    If $checker Then
        MsgBox (0, "one", "text one")
    EndIf
    
    If $checker Then
        make_one_one ()
    EndIf
    
EndFunc


Func general ()
    
    If $checker Then
        make_one ()
    EndIf
    
    If $checker Then    
        general ()
    EndIf
    
EndFunc

general ()

and again question how do the same without

If $checker Then
; some code
    EndIf

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

Link to comment
Share on other sites

This doesn't trigger the running Func to end and return which I believe the OP wants. ;)

Very true.

I once went right through a script of mine and added extra code to every function to unwind recursion, I added something like...

If $Pause Then Return SetError(999) at the beginning of every function and checked for it after a return from every function with...

If @Error = 999 Then Return @Error :) , It was a nightmare, and I wound up wrinting a script to add the code, then the penny dropped and

I just started the first script from scratch .. properly. ;)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Developers

Just put in these at strategic places:

If $checker Then Return

.. and as said: do not have a func call itself always unless you really intent recursion and know that it will not go too deep into it.

Work with a loop within the Func in you want the logic in the Func to repeat.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@sergeyWolf

Do you _really_ intend to have general invoke itself, or do you want to the body of general() loop until some condition?

The results are very different!

For instance this is a loop:

Paren(17)
ConsoleWrite(@LF)

Func Paren($n)
    $n = Abs($n)
    While ($n)
        ConsoleWrite("<")
        ConsoleWrite(">")
        $n -= 1
    WEnd
EndFunc

Now this uses recursion (a function invoking itself until some condition):

Global $n = 17

Paren()
ConsoleWrite(@LF)

Func Paren()
    If $n Then
        $n -= 1
        ConsoleWrite("<")
        Paren()
        ConsoleWrite(">")
    EndIf
EndFunc

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)

Link to comment
Share on other sites

Just put in these at strategic places:

If $checker Then Return

.. and as said: do not have a func all itself always unless you really intent recursion and know that it will not go too deep into it.

Work with a loop within the Func in you want the logic in the Func to repeat.

Jos

oh, i see

really **cks

it's seems like butthurt

thnx eveyone anyway

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

Link to comment
Share on other sites

  • Developers

oh, i see

really **cks

it's seems like butthurt

thnx eveyone anyway

Well, in general this has everything to do with proper program design, not language limitations.. :)

Have fun,

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Well, in general this has everything to do with proper program design, not language limitations.. ;)

Have fun,

Jos

i hoped to find some "magical" options for that or function :)

not important, i think to use your solution

WBR sergey

- I want program that crack all other programs...- Let's split up, i'll search this program and you'll find crack for it. ^_^'

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