Dinesh Posted February 25, 2011 Posted February 25, 2011 Hi All, I am new to AutoIT and trying to learn it. I want to write a AutoIT script which can return a value (integer/Array). My intension is to call the AutoIT script from some other program and need to know whether the execution of a pirticular command was successful or not (from AutoIT script). Ex: Here is my AutoIT script (my_script.exe): Global $ret_val = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Policy\v6.0", "30319"); if ($ret_val == "") Then ConsoleWrite (" The registry key was not found\n"); ConsoleWrite (" Value is ------------- "); ConsoleWrite ($ret_val); return 1; Else ConsoleWrite (" The registry key was found\n"); ConsoleWrite (" Value is ------------- "); ConsoleWrite ($ret_val); Return 0; EndIf (NOTE: This script is popping an error: 'Return' not allowed from Global scope. And I want to call this script (my_script.exe) from other script . Based on the return value of my_script.exe, I need to execute the commands. Can any one help me please? -- Thanks, Dinesh
Andreik Posted February 25, 2011 Posted February 25, 2011 Return make sense just in the body of a function, something like that: Global $ret_val MsgBox(0,"",MyFunction()) Func MyFunction() $ret_val = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Policy\v6.0", "30319"); if ($ret_val == "") Then ConsoleWrite (" The registry key was not found\n"); ConsoleWrite (" Value is ------------- "); ConsoleWrite ($ret_val); return 1; Else ConsoleWrite (" The registry key was found\n"); ConsoleWrite (" Value is ------------- "); ConsoleWrite ($ret_val); Return 0; EndIf EndFunc
FuryCell Posted February 25, 2011 Posted February 25, 2011 Exit can return an error value. $Sucess=False If $Success=False Then Exit 1 Exit 0 HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Dinesh Posted February 25, 2011 Author Posted February 25, 2011 Thank you dear Friends. I got the answer. exit code solves my problem. Thank you very much once again...
FuryCell Posted February 25, 2011 Posted February 25, 2011 Thank you dear Friends. I got the answer.exit code solves my problem. Thank you very much once again...No problem but next time make sure you post in the right forumhttp://www.autoitscript.com/forum/index.php?app=forums&module=forums§ion=rules&f=9 HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
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