Sign in to follow this  
Followers 0
erifash

Array Declaration

5 posts in this topic

#1 ·  Posted (edited)

Hi again!

I've been having serious issues with Dim. See, I have a variable and I don't know what it is and I need to use that variable to specify the length of an array. Only it says "Array variable subscript badly formatted." Here is the code:

Dim $a[Int($b + 1)]

I want to do that so I wouldn't have to do...

Dim $a[1001]

...and use up resources and hope that when i'm writing to the array that $b doesn't exceed 1000.

Help! :)

Edited by erifash

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

assuming $b has been defined already:

Dim $a[$b+1]

actually your version should work too. therefore $b is not a number

Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes, but $b is a decimal like 3.14159265 (not pi though, just example) so that's why I thought it being a non-interger screwed it up so I made it and interger by using Int().

Also, it still doesn't work... (see screenshot)

Edited by erifash

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

its your $b

This runs:

$b = 3.14159
Dim $a[int($b+1)]

$a[int($b)] = "hi"
msgbox(0,"",$a[int($b)])

EDIT

If your $b <= -1 it will break like it is for you, you probably need to add:

int(abs($:)+1)

Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

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