Compatibility: 6.7x and 6.8.x
When using a 2-Dimensional array, it is easy to think of it as a grid object. Each cellblock corresponds to a specific dimension (row and column).
For example:
ARRAY TEXT(arrText;3;3)
ARRAY TEXT(arrText;3;5)
ARRAY TEXT(arrText;5;5)
Resizing a 2-dimensional array is not as straightforward as resizing a 1-dimensional array. Here is a project method that will allow you to resize a 2-Dimensional Array.
` Project Method: SetSize_2DArray
` Description: Set the number of elements in a 2D-Array
`
` $1 - Pointer to a 2D-Array
` $2 - Number of row (First dimension) to be added or deleted
` $3 - Number of column (Second dimension) to be added or deleted
` $4 - add for adding rows and columns / del for deleting rows and columns
C_POINTER($1;arrPtr)
arrPtr:=$1
If (Type(arrPtr->)=13)
C_LONGINT($2;$D1;$3;$D2)
$D1:=$2
$D2:=$3
If (($D1<0) | ($D2<0))
` Unhandled parameter[s]: negative number
Else
C_TEXT($4;$action)
$action:=$4
C_LONGINT($D1_Size;$D2_Size)
$D1_Size:=Size of array(arrPtr->)
$D2_Size:=Size of array(arrPtr->{$D1_Size})
Case of
: ($action="Ins")
` Adding row[s]
INSERT ELEMENT(arrPtr->;$D1_Size+1;$D1)
$D1_Size:=Size of array(arrPtr->)
` Adding column[s]
C_LONGINT($row;$col)
For ($row;0;$D1_Size)
INSERT ELEMENT(arrPtr->{$row};$D2_Size+1;$D2)
End for
: ($action="del")
` deleting row[s]
DELETE ELEMENT(arrPtr->;($D1_Size-$D1)+1;$D1)
$D1_Size:=Size of array(arrPtr->)
` deleting column[s]
C_LONGINT($row)
For ($row;0;$D1_Size)
DELETE ELEMENT(arrPtr->{$row};($D2_Size-$D2)+1;$D2)
End for
Else
` Invalid action
End case
End if
Else
` Invalid: The passed pointer is not a pointer to a 2D-Array
End if