Sign in to follow this  
Followers 0
Overlord

exit but don't exit

26 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

couple questions.

1. if regread returns 1 then exit?

2. well if returns not 1 then exit?

I think you are using it incorrectly, (if i understand correctly what you want done)

then try this

if $check <> "" then exit
Edited by beerman

 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

i think you could still just use Return and it would exit the include script.

or was that php...? :lmao:


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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()

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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]

Share this post


Link to post
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()

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

If Not $check = 1 then

Endif

;script continues on here

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

If Not $check = 1 then

Endif

;script continues on here

???

that won't do anything at all...


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
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.


[center]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.[/center]

Share this post


Link to post
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- #

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
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- #

Share this post


Link to post
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]

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