Jump to content

Is there any concept of external variable in AutoIt


omi
 Share

Recommended Posts

I want to make some variables as gobal and access them in some another file for that i want to make it extern. how can i make that.

Thnaks in advance.

I don't think you can declare variables so that they are accessible outside the file. What you can do is simulate a "Property" as used in other languages like C++ C# and Delphi. Use functions in a file that set and retrieve the state of a variable and include the file in your script. For example if your "extern" variable would be a color value you might want to have $MyColor accessible from all scripts using your routines. So you would need a function or functions to set and return its value like SetMyColor GetMyColor etc..

Not sure about .dll libraries and AutoIt3 though. COM has properties also.

Link to comment
Share on other sites

I don't think you can declare variables so that they are accessible outside the file. What you can do is simulate a "Property" as used in other languages like C++ C# and Delphi. Use functions in a file that set and retrieve the state of a variable and include the file in your script. For example if your "extern" variable would be a color value you might want to have $MyColor accessible from all scripts using your routines. So you would need a function or functions to set and return its value like SetMyColor GetMyColor etc..

Not sure about .dll libraries and AutoIt3 though. COM has properties also.

Thank you very much for your help!!

Link to comment
Share on other sites

Thank you very much for your help!!

Sure thing. If you find out any more details I'd appreciate a heads up. I'm not sure exactly how AutoIt handles variables. For instance in C or C++ you can have a "static" variable inside a function that doesn't go away when the function returns... and use that to store the value of Get/Set functions(at least in C, in C++ you'd just use a private or protected member variable but C doesn't have classes so you improvise.) I'm not sure exactly how to approach it in AutoIt but if you mess around with it you'll probably find out the exact mechanism. :P

Esp. if you have any kind of access from multiple places where the order of execution is not definite(like threads or some kind of cooperative multi-tasking functions or something) you'd want to serialize access to the variable.

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