EDIT : You also need a dimension called ValueString, this contains a numeric element called Value and a string element called String. This allows the array to hold numbers or strings.
To build a 2d array called MyArray that is 100 x 1 you'd call the TI in the following way. The 1 bit comes from the ValueString dimension.
Code: Select all
ans=ExecuteProcess('ADMIN - Create Array Cube',
'Suffix' , 'MyArray',
'CreateDelete1or0', 1,
'ElementsInD1',100,
'ElementsInD2',0,
'ElementsInD3',0,
'ElementsInD4',0);
Code: Select all
ans=ExecuteProcess('ADMIN - Create Array Cube',
'Suffix' , 'MyArray',
'CreateDelete1or0', 0,
'ElementsInD1',100,
'ElementsInD2',0,
'ElementsInD3',0,
'ElementsInD4',0);
Prolog
Code: Select all
#TI to create an arraycube
ElType='N';
InsertionPoint='';
If(CreateDelete1or0=1);
#Creation section
#Dim 1
ixCount=1;
DimName=Suffix | '1';
DimensionCreate(DimName);
#Populate the dimension
While (ixCount <= ElementsInD1);
DimensionElementInsert(DimName, InsertionPoint, NumberToString(ixCount), ElType);
ixCount=ixCount+1;
End;
#Dim2
If (ElementsInD2>0);
ixCount=1;
DimName=Suffix | '2';
DimensionCreate(DimName);
#Populate the dimension
While (ixCount <= ElementsInD2);
DimensionElementInsert(DimName, InsertionPoint, NumberToString(ixCount), ElType);
ixCount=ixCount+1;
End;
EndIf;
#Dim3
If (ElementsInD3>0);
ixCount=1;
DimName=Suffix | '3';
DimensionCreate(DimName);
#Populate the dimension
While (ixCount <= ElementsInD3);
DimensionElementInsert(DimName, InsertionPoint, NumberToString(ixCount), ElType);
ixCount=ixCount+1;
End;
EndIf;
#Dim4
If (ElementsInD4>0);
ixCount=1;
DimName=Suffix | '4';
DimensionCreate(DimName);
#Populate the dimension
While (ixCount <= ElementsInD4);
DimensionElementInsert(DimName, InsertionPoint, NumberToString(ixCount), ElType);
ixCount=ixCount+1;
End;
EndIf;
#Create the Cube
If (ElementsInD4>0);
CubeCreate (Suffix, Suffix | '1', Suffix | '2', Suffix | '3', Suffix | '4', 'ValueString');
ElseIf(ElementsInD3>0);
CubeCreate (Suffix, Suffix | '1', Suffix | '2', Suffix | '3', 'ValueString');
ElseIf(ElementsInD2>0);
CubeCreate (Suffix, Suffix | '1', Suffix | '2', 'ValueString');
ElseIf(ElementsInD1>0);
CubeCreate (Suffix, Suffix | '1', 'ValueString');
EndIf;
#End of creation section
EndIf;
Code: Select all
#Deletion Section
If(CreateDelete1or0=0);
RefDimName='}Dimensions';
CubeDestroy(Suffix);
If ( Dimix( RefDimName, Suffix |'1')>0);
DimensionDestroy(Suffix |'1');
EndIf;
If ( Dimix( RefDimName, Suffix |'2')>0);
DimensionDestroy(Suffix |'2');
EndIf;
If ( Dimix( RefDimName, Suffix |'3')>0);
DimensionDestroy(Suffix |'3');
EndIf;
If ( Dimix( RefDimName, Suffix |'4')>0);
DimensionDestroy(Suffix |'4');
EndIf;
#End of delete section.
EndIf;
I have a vague recollection of putting this up before put I couldn't see it when I searched.
Anyway if anyone finds a use for the code you're welcome!
Cheers