Jump to content
Sign in to follow this  

Multidimensional Array assign

Recommended Posts

I'm having trouble with this and I'm not sure why, I am reorganizing an array based on name and level alphabetically. Pardon all my msgboxes and arraydisplays, just me trying to figure it out.

It wont let me assign $newLowTemp = $aPlannedArray[$i], $i at the time it crashes is 6, the array itself has far more than 6, it ranges from 0 to 205 and can be seen with the above _ArrayDisplay($aPlannedArray, "")

Am I just not allowed to assign the first half of a multidimensional array? $aPlannedArray[$i] instead of $aPlannedArray[$i][somethingelse]

Func PlanAlph($min, $max)
   MsgBox($MB_SYSTEMMODAL, "",$min + 1&"  "&$max + 1)
   MsgBox($MB_SYSTEMMODAL, "",$aPlannedArray[6][$dtNAME])
   _ArrayDisplay($aPlannedArray, "")
   For $i = $min + 1 To $max
      For $j = $min To $i
         If StringCompare($aPlannedArray[$i][$dtNAME] & String($aPlannedArray[$i][$dtLVL]), $aPlannedArray[$j][$dtNAME] & String($aPlannedArray[$i][$dtLVL])) < 0 Then
               MsgBox($MB_SYSTEMMODAL, "",$i)
            _ArrayDisplay($aPlannedArray[6], "")
            Local $newLowTemp[4]
            $newLowTemp = $aPlannedArray[$i]
            $newLowTemp[$dtSLOT] = $aPlannedArray[$j][$dtSLOT]
            For $n = $aPlannedArray[$i] To $aPlannedArray[$j] + 1 step -1
               $aPlannedArray[$n][$dtSLOT] += 1
               $aPlannedArray[$n] = $aPlannedArray[$n - 1]
            $aPlannedArray[$j] = $newLowTemp

Here is where I defined it

Global $aGameArray[$dTOTALNODES + 1][$dNODEATTRIBUTES]
Global $aPlannedArray[$dTOTALNODES + 1][4]
Global $numNodes = 0
For $i = 0 To $dTOTALNODES
   $aPlannedArray[$i][$dtSLOT]      = $i
   $aPlannedArray[$i][$dtID]        = $i
   $aPlannedArray[$i][$dtNAME]      = "Empty"
   $aPlannedArray[$i][$dtLVL]       = False

   $aGameArray[$i][$dID]            = $i
   $aGameArray[$i][$dSLOT]          = $i
   $aGameArray[$i][$dTYPE]          = False
   $aGameArray[$i][$dNAME]          = "Empty"
   $aGameArray[$i][$dAFFIX]         = False
   $aGameArray[$i][$dTAGS]          = False
   $aGameArray[$i][$dILEVEL]        = False
   $aGameArray[$i][$dHSTAT]         = False
   $aGameArray[$i][$dDESCRIPTION]   = False
   $aGameArray[$i][$dTARGSLOT]      = False

Thanks for any help sorry if I am missing something basic


I should probably include the error message, 

$newLowTemp = $aPlannedArray[$i]

$newLowTemp = ^ ERROR

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

I know this usually means it either isn't an array or isn't large enough but it is an array and it is large enough..

Edited by Barkze

Share this post

Link to post
Share on other sites

ell I got it working, not sure why you can't assign it that way but I had to do it all one at a time.

It wasn't the $i that it didn't like it was the fact that I was assigning a [4] array to another [4] array... or something?

Local $newLowTemp[4] = [ $aPlannedArray[$j][$dtSLOT], $aPlannedArray[$i][$dtID], $aPlannedArray[$i][$dtNAME], $aPlannedArray[$i][$dtLVL] ]
Edited by Barkze

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  

  • Create New...