Sign in to follow this  
Followers 0
Dinesh

AutoIT script to return a value

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Thank you dear Friends. I got the answer.

exit code solves my problem. Thank you very much once again...

Share this post


Link to post
Share on other sites

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 forum

http://www.autoitscript.com/forum/index.php?app=forums&module=forums&section=rules&f=9


HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

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