Jump to content

Need help with small script...


Hollinar
 Share

Recommended Posts

Okay, a piece of a script I'm making contains code similar to this:

Dim $var1 = InputBox("Please enter a number", "Please entar a number.", "", " M")
        Dim $var2
        Dim $e = 0
        While $e < $var1 + 1
            $e = $e + 1
            Global $stat[$e]
            $var2[$e] = InputBox("Enter a number", "Enter a number.", "", " M")
        WEnd

Now, when I run this code it says:

Line 0  (File "<edited out>"):

$var2[$e] = InputBox("Enter a number", "Enter a number.", "", " M")
$var2^ ERROR

Error: Badly formated variable or macro.

Is there a way to get what I need done? or will I have to increase the code exponentially to compensate?

Link to comment
Share on other sites

You're DIMing $var2 as a string and then trying to use it as an array. An array of [0] size is just a variable. Use:

$var2 = InputBox("Enter a number", "Enter a number.", "", " M")

If you need an array, then declare it as an array and ReDim as needed

Dim $var1, $var2[1], $e
Global $stat[1]
$var1 = InputBox("Please enter a number", "Please entar a number.", "", " M")
     ReDim $var2[$var1+1]
     $e = 0
     While $e < $var1 + 1
          $e = $e + 1
          $var2[$e] = InputBox("Enter a number", "Enter a number.", "", " M")
     WEnd

ReDim $stat[] as needed.

If you don't know the size of the array, use UBound.

Link to comment
Share on other sites

Excellent, thanks... Perhaps I'll post the script when I've got it past the "heavy-editing-beta" stage... I make changes to it multiple times a day... it's at 484 lines of code right now, and it's an auto-leveller/trainer bot for a game(even though the game is older)

EDIT------------

I feel I should point out that the $stat variable was clutter from an old version of the function that statement resides in, and I failed to remove it... I also must thank you for pointing it out, or else it probably would have gone un-noticed until I released the code :P

Edited by Hollinar
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...