Jump to content

Array error


Xenos
 Share

Recommended Posts

Hey all!

Just wondering if you have ever had this error and what your suggestions might be?

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

I know it is a fairly self explanitory message but it is very strange.

Backstory: I have a script that asks for the number of days I need to run reports for. If I put 1, 2, or 3 days it runs fine. Anything else >3 kills it with this error message.

I might be able to provide some code but it is fairly sensitive data so.

$ANSWER = user input
Do
$I = $I + 1
$IPATHCOUNT = $IPATHCOUNT + 1

$PATH[$I] = $LOGPATH & "\" & "Logs" & "\" & $DATEARRAY[$I][2] & "\" & $DATEARRAY[$I][3] & "-" & $DATEARRAY[$I][4] & "\" & $DATEARRAY[$I][5] & "-" & $DATEARRAY[$I][6]

FileWrite($FILE, 'd:\folders"Error     "' & $PATH[$I] & "\" & " *.log /C/S/L >d:\folders"& $JNJ[7] & "-" & $DATEARRAY[$I][5] & "-" & $DATEARRAY[$I][4] & "-" & $DATEARRAY[$I][2] & ".txt" & @CRLF)

$PATH[$I] = $JNJ[3] & "\" & $JNJ[4] & "\" & $JNJ[5] & "\" & $JNJ[6] & "\" & $JNJ[7] & "\Logs\" & $DATEARRAY[$I][2] & "\" & $DATEARRAY[$I][3] & "-" & $DATEARRAY[$I][4] & "\" & $DATEARRAY[$I][5] & "-" & $DATEARRAY[$I][6]

$PATHARRAY[$IPATHCOUNT] = $JNJ[3] & "\" & $JNJ[4] & "\" & $JNJ[5] & "\" & $JNJ[6] & "\" & $JNJ[7] & "\Logs\" & $DATEARRAY[$I][2] & "\" & $DATEARRAY[$I][3] & "-" & $DATEARRAY[$I][4] & "\" & $DATEARRAY[$I][5] & "-" & $DATEARRAY[$I][6]

Until $I = $ANSWER

I know this is MASSIVE code amount for a forum help but if anybody out there has questions or would like more code or has any sort of direction to point me in: I would really appreciate it!

Not as-Newbie

Link to comment
Share on other sites

Hey all!

Just wondering if you have ever had this error and what your suggestions might be?

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

I know it is a fairly self explanitory message but it is very strange.

Backstory: I have a script that asks for the number of days I need to run reports for. If I put 1, 2, or 3 days it runs fine. Anything else >3 kills it with this error message.

I might be able to provide some code but it is fairly sensitive data so.

$ANSWER = user input
Do
$I = $I + 1
$IPATHCOUNT = $IPATHCOUNT + 1

$PATH[$I] = $LOGPATH & "\" & "Logs" & "\" & $DATEARRAY[$I][2] & "\" & $DATEARRAY[$I][3] & "-" & $DATEARRAY[$I][4] & "\" & $DATEARRAY[$I][5] & "-" & $DATEARRAY[$I][6]

FileWrite($FILE, 'd:\folders"Error     "' & $PATH[$I] & "\" & " *.log /C/S/L >d:\folders"& $JNJ[7] & "-" & $DATEARRAY[$I][5] & "-" & $DATEARRAY[$I][4] & "-" & $DATEARRAY[$I][2] & ".txt" & @CRLF)

$PATH[$I] = $JNJ[3] & "\" & $JNJ[4] & "\" & $JNJ[5] & "\" & $JNJ[6] & "\" & $JNJ[7] & "\Logs\" & $DATEARRAY[$I][2] & "\" & $DATEARRAY[$I][3] & "-" & $DATEARRAY[$I][4] & "\" & $DATEARRAY[$I][5] & "-" & $DATEARRAY[$I][6]

$PATHARRAY[$IPATHCOUNT] = $JNJ[3] & "\" & $JNJ[4] & "\" & $JNJ[5] & "\" & $JNJ[6] & "\" & $JNJ[7] & "\Logs\" & $DATEARRAY[$I][2] & "\" & $DATEARRAY[$I][3] & "-" & $DATEARRAY[$I][4] & "\" & $DATEARRAY[$I][5] & "-" & $DATEARRAY[$I][6]

Until $I = $ANSWER

I know this is MASSIVE code amount for a forum help but if anybody out there has questions or would like more code or has any sort of direction to point me in: I would really appreciate it!

Not as-Newbie

<{POST_SNAPBACK}>

Make sure your DIMing your arrays to the user input. For example

$DATEARRAY[$I][$X] would be called immediately after the user input box as

$X = 6
Do
$ANSWER = InputBox("Title","Question?","Default")
Until not ($answer = "Default" or $answer = "") and not @error
DIM $DATEARRAY[$ANSWER][$X]
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Make sure your DIMing your arrays to the user input.  For example

$DATEARRAY[$I][4] would be called immediately after the user input box as

DIM $DATEARRAY[$ANSWER][6]

<{POST_SNAPBACK}>

This makes total sense and I really appreciate your help; but why does the script run just fine if I use 1, 2 or 3 for input?

Thanks! Not trying to be a smart a$$ just curious.

Newbs

Link to comment
Share on other sites

This makes total sense and I really appreciate your help; but why does the script run just fine if I use 1, 2 or 3 for input?

Thanks! Not trying to be a smart a$$ just curious.

Newbs

<{POST_SNAPBACK}>

Because of your initial DIM statement.

It probably reads DIM $DATEARRAY[3][6] and doesn't take into account other possibilities beyond 3.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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...