Jump to content
Sign in to follow this  
skippynz

array error

Recommended Posts

skippynz

hi guys

can you tell me why i get this error ": ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: " in SciTe when running this ?? im sure it use to work before i updated to the latest Beta.

For $x = 1 To $responding_1[0]
    $responding_1a = StringStripCR($responding_1[$x])
    If $responding_1a <> '' Then
        FileWriteLine(@ScriptDir & "\checks.txt", $responding_1a)
    EndIf
Next

Share this post


Link to post
Share on other sites
SmOke_N

Try this and see how many elements $responding_1 is holding::

MsgBox(0, 'Element Test', 'Number of elements found for this array: ' & Ubound($responding_1) - 1)
Use this in place of the For/Next loop


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.

Share this post


Link to post
Share on other sites
skippynz

Try this and see how many elements $responding_1 is holding::

MsgBox(0, 'Element Test', 'Number of elements found for this array: ' & Ubound($responding_1) - 1)
Use this in place of the For/Next loop
says there are 25 elements.

to make it clear its failing on this line

$responding_1a = StringStripCR($responding_1[$x])

Edited by craig.gill

Share this post


Link to post
Share on other sites
SmOke_N

It's not failing on that line for me, it's not even making it to the loop, so $responding[0] is the issue.... Try this:

Dim $responding_1[2]
$responding_1[1] = 'This is a test' & @CR & 'And only a test'
MsgBox(0, UBound($responding_1) - 1, $responding_1[1])
For $x = 1 To UBound($responding_1) - 1
    MsgBox(0, '', $responding_1[$x])
    $responding_1a = StringStripCR($responding_1[$x])
    If $responding_1a <> '' Then
        ConsoleWrite($responding_1a);FileWriteLine(@ScriptDir & "\checks.txt", $responding_1a)
    EndIf
Next


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.

Share this post


Link to post
Share on other sites
skippynz

It's not failing on that line for me, it's not even making it to the loop, so $responding[0] is the issue.... Try this:

Dim $responding_1[2]
$responding_1[1] = 'This is a test' & @CR & 'And only a test'
MsgBox(0, UBound($responding_1) - 1, $responding_1[1])
For $x = 1 To UBound($responding_1) - 1
    MsgBox(0, '', $responding_1[$x])
    $responding_1a = StringStripCR($responding_1[$x])
    If $responding_1a <> '' Then
        ConsoleWrite($responding_1a);FileWriteLine(@ScriptDir & "\checks.txt", $responding_1a)
    EndIf
Next
so i should be using UBound($responding_1) - 1 instead of $responding_1[$x]) on the For $x = 1 to line ? is that right ? Edited by craig.gill

Share this post


Link to post
Share on other sites
skippynz

so i should be using UBound($responding_1) - 1 instead of $responding_1[$x]) on the For $x = 1 to line ? is that right ?

ok just tested and worked a treat... thanks for that SmOke_N

your help is appreciated.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.