Jump to content

exit but don't exit


 Share

Recommended Posts

Hey guys, I have a small problem here where I don't see a easy workaround with my auto-skills.

I have a few scripts and want to include a certain script always using #include but the main problem is this line. It quit's the entire program, not just that part of the script.

$check = RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog")
If $check = 1 Then Exit ;should be exitscript

There's more code below this but that aint a problem. I just want it to stop executing this module if the key is in the registry already.

Edited by Overlord
Link to comment
Share on other sites

There's more code below this but that aint a problem. I just want it to stop executing this module if the key is in the registry already.

Instead of "then exit" use "then return" (assuming that you mean "function" when you say "module") ? :lmao:
Link to comment
Share on other sites

Instead of "then exit" use "then return" (assuming that you mean "function" when you say "module") ? :lmao:

nono, it's not part of a function. otherwise I would have just used endfunc()

it's the first rule of a entire script that needs to notify me if a new user comes on our voice-server. But I don't want 1000 emails that the same person had logged in.

each time a user logs in the number goes up in recog but each time it's a new user I want to know who it was so I get a mail

EDIT: when I talk about module I mean this script since it's included in a larger script

Edited by Overlord
Link to comment
Share on other sites

you could make seperate functions, and then assign the "call" function to a variable, and if the regread function = the return value that you set... then you could stop it?

BTW: I don't think you can use endfunc in an if statement, because then it will give you an error about there being more endfuncs then there are functions... thats just what I have noticed...

EDIT: like this

$whatever = Call("regreadfunction)

If $whatever <> $myreturnvalue Then

$whatever2 = Call("therestofthescript)

and i think it is sort of obvious how you would put the script into functions from that

Edited by Kickassjoe

What goes around comes around... Payback's a bitch.

Link to comment
Share on other sites

Hey guys, I have a small problem here where I don't see a easy workaround with my auto-skills.

I have a few scripts and want to include a certain script always using #include but the main problem is this line. It quit's the entire program, not just that part of the script.

$check = RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog")
If $check = 1 Then Exit ;should be exitscript

There's more code below this but that aint a problem. I just want it to stop executing this module if the key is in the registry already.

Perhaps regread return the string "1". If yes "1" is not equal to 1 :lmao:
Link to comment
Share on other sites

nono, it's not part of a function. otherwise I would have just used endfunc()

As others allready mentioned, that does not work. :lmao:

What about just simply jumping over the rest of the script ? Like this :

$check = RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog")
If $check <> 1 Then 
  ; rest of script here
endif
Link to comment
Share on other sites

nono, it's not part of a function. otherwise I would have just used endfunc()

it's the first rule of a entire script that needs to notify me if a new user comes on our voice-server. But I don't want 1000 emails that the same person had logged in.

each time a user logs in the number goes up in recog but each time it's a new user I want to know who it was so I get a mail

EDIT: when I talk about module I mean this script since it's included in a larger script

It's a bug generator practice to have an #include as a script wich interacts with the calling script

you have to modify your included script in a function

eg (pseudo-code)

func notifyMeOfNewUser()

....

if newUser then

....

return

endif

....

end func

.....

other functions of the included script

in the calling script let the #include statement and add a new line which call the function

notifyMeOfNewUser()

Link to comment
Share on other sites

are you sure your regread is returning a 1?

Check with a message box.

MsgBox(0, "",isnumber( RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog")))

and..

what jpm said...

Its probably returning an string not a number.

edited by JPM as the output was not proving the error. Isnumber is madatory :lmao:

Edited by jpm
Link to comment
Share on other sites

This is maybe stupid.. But should it not be as this:

$check = RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog")
If $check = 1 Then
Exit
EndIf
Check the help file under "If...Then", it states in part:

This version of the If statement is used to execute a single statement without the overhead of an EndIf.

@Overlord,

As best I can tell from your posts, your individual scripts seem to work for you. You would like to combine several existing/functioning scripts into one main script (using #include) without making the other scripts into functions. One of the "included" scripts causes your main script to exit.

This seems to be an easy fix from BitRot:

http://www.autoitscript.com/forum/index.ph...st&p=252423

That should allow your main script to keep going as well as leave your smaller script as a functioning standalone script...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

@Overlord,

As best I can tell from your posts, your individual scripts seem to work for you. You would like to combine several existing/functioning scripts into one main script (using #include) without making the other scripts into functions. One of the "included" scripts causes your main script to exit.

This seems to be an easy fix from BitRot:

http://www.autoitscript.com/forum/index.ph...st&p=252423

That should allow your main script to keep going as well as leave your smaller script as a functioning standalone script...

If Overlord wants to keep the called script as a standalone one , a solution may be

make a function like I said with the whole script

func nameOfFunctionScript()

.....

endfunc

Write a single line after the variables statements with the line

nameOfFunctionScript()

Link to comment
Share on other sites

  • Moderators

Everyone is still missing what jpm said and what Chris itterated, you should work on first retrieving the correct value, in order to test any of the theory's above.

If Int(RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog")) = 1 Then ... Here you are comparing an Integer to an Integer.

If RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog") = 1 Then ... Here you are comparing a String to an Integer.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Everyone is still missing what jpm said and what Chris itterated, you should work on first retrieving the correct value, in order to test any of the theory's above.

If Int(RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog")) = 1 Then ... Here you are comparing an Integer to an Integer.

If RegRead("HKEY_CURRENT_USER\Software\Ventrilo\Automation","recog") = 1 Then ... Here you are comparing a String to an Integer.

So, Should be = "1"?
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

  • Moderators

So, Should be = "1"?

However you do it, or need to do it. My point was, compare a string to a string, or make the the string a Number/Int and compare it to a Number/Int. But don't try and compare a string to a Number/Int.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

However you do it, or need to do it. My point was, compare a string to a string, or make the the string a Number/Int and compare it to a Number/Int. But don't try and compare a string to a Number/Int.

Ah.
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

It's a bug generator practice to have an #include as a script wich interacts with the calling script...

I concur [having made several buggy scripts in just that way], but keep in mind that for those of us that do not use good coding practices, turning an "included" script into a function may break more things than it is worth. For instance, the last time I tried to do what you are suggesting, I ran into problems with variable scope - which I don't understand all that well (and I often don't declare my variables).

My point being: adding one "EndIf" line of code to the end of the existing/working/standalone script should cause the least problems for the senario mentioned by the OP... if I understand the senario in the first place.

That said, I suppose that I should not encourage anyone to code like me :-)

You (and others in this thread) are correct - a well made function called by a well made main script is the best way to go.

@SmOke_N,

Maybe I have read the thread incorrectly. I thought that the scripts to be included (the modules) work as standalone code. To me that means that the script works for true and false of the "If" line of code in the post... but now that I re-read things, perhaps that is not the case. I actually repeated jpm's admonishment to check that return value in my first post to this thread, but then took it out.

The OP is going to awake to a lot of input :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

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