Sign in to follow this  
Followers 0
brodie28

Declaring a global variable

3 posts in this topic

I am using the string split function to create an array from a string.

$commands = StringSplit ( $command, " ", 1)

It works fine, but in my other functions when I try to use this array I get an error for using a variable before it is declared. I tried this but it did not fix it.

global $commands = StringSplit ( $command, " ", 1)

Any ideas? I know the solution will be really simple, but oh well....

Share this post


Link to post
Share on other sites



Put Global $commands at the top of your script, and use your first code example to define/redefine the variable.

Share this post


Link to post
Share on other sites

Is $command already global? If not, you're trying to use it in a local scope within a function, and the value isn't passed.


[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

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