Jump to content

Variable Errors


Recommended Posts

Im writing a big script. Only 300 lines and growing. While i work on it i usually save and try it to make sure it works. So it works for awhile then gives me the "variable is not declared" for every variable i have. The variables work while not in a function but when in a function they "variable is not declared"

Snippet of code

$moder = IniRead ( $ini, "Loader", "Modes", "-w -skiptobnet" )

Declaring variable

Func Load ()
    $window = StringinStr ( $moder , '-w', 0, 1 )
    If $window = 0 Then
    MsgBox ( 1, "Error", "This script needs to be run in windows mode" )
    Exit
    Else
EndIf
EndFunc

Using $moder in Func load () gives me error

Edit:

If i take some code from it works in a differernt script but not in my script

Edited by Chip
Link to comment
Share on other sites

  • Moderators

How are you declaring the variables?

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

Im writing a big script. Only 300 lines and growing. While i work on it i usually save and try it to make sure it works. So it works for awhile then gives me the "variable is not declared" for every variable i have. The variables work while not in a function but when in a function they "variable is not declared"

Snippet of code

$moder = IniRead ( $ini, "Loader", "Modes", "-w -skiptobnet" )

Declaring variable

Func Load ()
    $window = StringinStr ( $moder , '-w', 0, 1 )
    If $window = 0 Then
    MsgBox ( 1, "Error", "This script needs to be run in windows mode" )
    Exit
    Else
EndIf
EndFunc

Using $moder in Func load () gives me error

Edit:

If i take some code from it works in a differernt script but not in my script

If the $moder = IniRead() is inside a function, and $moder is not declared outside any function then it is local by default, and therefore not avaiable outside the function.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...