Overlord Posted October 15, 2006 Share Posted October 15, 2006 (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 October 15, 2006 by Overlord Link to comment Share on other sites More sharing options...
BitRot Posted October 15, 2006 Share Posted October 15, 2006 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") ? Link to comment Share on other sites More sharing options...
Overlord Posted October 15, 2006 Author Share Posted October 15, 2006 (edited) Instead of "then exit" use "then return" (assuming that you mean "function" when you say "module") ? 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 mailEDIT: when I talk about module I mean this script since it's included in a larger script Edited October 15, 2006 by Overlord Link to comment Share on other sites More sharing options...
Kickassjoe Posted October 15, 2006 Share Posted October 15, 2006 (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 October 15, 2006 by Kickassjoe What goes around comes around... Payback's a bitch. Link to comment Share on other sites More sharing options...
jpm Posted October 15, 2006 Share Posted October 15, 2006 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 Link to comment Share on other sites More sharing options...
Somerset Posted October 15, 2006 Share Posted October 15, 2006 (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 October 15, 2006 by beerman Link to comment Share on other sites More sharing options...
theguy0000 Posted October 15, 2006 Share Posted October 15, 2006 i think you could still just use Return and it would exit the include script. or was that php...? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
BitRot Posted October 15, 2006 Share Posted October 15, 2006 nono, it's not part of a function. otherwise I would have just used endfunc()As others allready mentioned, that does not work. 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 More sharing options...
XInFisk Posted October 15, 2006 Share Posted October 15, 2006 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 Link to comment Share on other sites More sharing options...
tresa Posted October 15, 2006 Share Posted October 15, 2006 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 mailEDIT: when I talk about module I mean this script since it's included in a larger scriptIt's a bug generator practice to have an #include as a script wich interacts with the calling scriptyou have to modify your included script in a functioneg (pseudo-code)func notifyMeOfNewUser()....if newUser then....returnendif....end func.....other functions of the included scriptin the calling script let the #include statement and add a new line which call the functionnotifyMeOfNewUser() Link to comment Share on other sites More sharing options...
cppman Posted October 15, 2006 Share Posted October 15, 2006 (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 Edited October 15, 2006 by jpm Miva OS Project Link to comment Share on other sites More sharing options...
herewasplato Posted October 15, 2006 Share Posted October 15, 2006 (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 EndIfCheck 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 October 15, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
tresa Posted October 15, 2006 Share Posted October 15, 2006 @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=252423That 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 bemake a function like I said with the whole script func nameOfFunctionScript().....endfuncWrite a single line after the variables statements with the linenameOfFunctionScript() Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted October 15, 2006 Share Posted October 15, 2006 (edited) If Not $check = 1 then Endif ;script continues on here Edited October 15, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
theguy0000 Posted October 15, 2006 Share Posted October 15, 2006 If Not $check = 1 thenEndif;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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 15, 2006 Moderators Share Posted October 15, 2006 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 More sharing options...
AzKay Posted October 15, 2006 Share Posted October 15, 2006 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 More sharing options...
Moderators SmOke_N Posted October 15, 2006 Moderators Share Posted October 15, 2006 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 More sharing options...
AzKay Posted October 15, 2006 Share Posted October 15, 2006 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 More sharing options...
herewasplato Posted October 15, 2006 Share Posted October 15, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now