DIM |
dim is used to find the dimensions of a variable.
dim( variable [, [ '-' ] no_dim ] )
|
Element |
Description |
Restrictions |
|
variable |
Name of the variable whose
dimensions are required, in the form: |
None. |
|
no_dim |
Integer expression giving the number of the dimension to be returned, with or without a preceding '-'. The default for this value is 1. |
From 0 to number of
dimensions of the |
# Test of existence of a variable If dim([M:TOTO]VAR1) < 0
Errbox "Non-existent variable !" Endif #Declaration of a table 2*3*4 of strings with maximum length 8Char TOTO(8) (5..16,3,4)
Infbox num$(type(TOTO))-num$(dim(TOTO))
For I=1 To dim (TOTO, 0)
Infbox num$(dim(TOTO, I))-num$(dim(TOTO, -I))
Next I # This programme displays: # 18 12 # 12 5 3 0 4 0
dim returns a code for the first dimension of the variable given as parameter, if one parameter is given.
When two parameters are used, the second is a dimension number (from 1 to 4 maximum) for the variable, with or without the preceding '-'. If this number is positive, the value returned is the number of elements of the dimension given. Otherwise, it is the index for the start of this dimension. This syntax can only be used for a variable with several dimensions. If the second argument is null, the number of dimensions of the variable (from 1 to 4 maximum) is given.
The result of this function is an Integer type.
dim returns -1 if the variable does not exist. This allows a test of the existence of a variable.
|
Error |
Description |
|
ERDOM (50) |
The argument does not match a variable. no_dim exceeds the number of dimensions or has a negative value. |
|
|