| Directives |
|
| Formats | 1. Define
Array: DIM
array_name[$](subscript_1[,subscript_2[,subscript_3]]) 2. Define Composite String: DIM var$:IOL=iolref 3. Initialize String: DIM var$(len[,char$])[,...] 4. Define Structured String DIM var$::structure$
|
||||||||||||||||||||||||||||
| Description | Use the DIM
directive to define an array, to define a composite
string or to initialize a string. Refer to the DIM(
) Function,
to read the total number, minimum number and maximum
number of elements in an array. The maximum number of elements in an array (regardless of the number of dimensions) is 10000032767 for 32-bit ProvideX (Version 4.10). That is, you can use either DIM A$[1:32767] or DIM A$[32766] (zero based). (The limit in 16-Bit PVX Windows and PVX DOS remains 8192 elements.). To delete an array use the CLEAR directive as in CLEAR A$[ALL] |
||||||||||||||||||||||||||||
| *Note* | For numeric arrays you can use either parenthesis ( )or square brackets [ ] to define arrays or reference elements. For string arrays, use square brackets [ ] to avoid confusion with substrings. Internally all arrays have three subscripts. An array defined as X$[4] has values 0:4 for subscript 1, 0:0 for subscript 2, and 0:0 for subscript 3. However, specifying the unused subscripts is unnecessary. | ||||||||||||||||||||||||||||
| Format 1 | Define Array
Use the DIM directive to define an array with one, two or three dimensions. Specify the dimensions using the values in the DIM statement. The dimensions of the array are defined as
If you omit the minimum dimension, then ProvideX uses the default minimum, 0 (zero). Examples:
When you refer to items in arrays, the lowest subscript is the minimum value specified, the highest is the maximum value specified. You can redefine existing arrays using the DIM statement. The values of all elements in the array are automatically initialized to zero or null by the DIM statement. The following example defines a three-dimensional array with three elements (0 through 2) in each dimension for a total of 27 elements:
The following example defines dimension one with 10 elements (1 through 10). Dimensions 2 and 3 are 0:0:
|
||||||||||||||||||||||||||||
| Format 2 | Define Composite String DIM var$:IOL=iolref Use this format of the DIM directive to define a composite string variable consisting of the fields specified in an IOList. The variable returns a string made up of the fields you specified in the IOList. If you modify the variable (e.g., by adding a field) ProvideX will modify the fields in the IOList. Field names in the IOList are prefixed by the name of the variable and a dot (.); e.g., 0010 DIM CST$:IOL=1000
yields the string CST$ consisting of CST.NAME$, CST.ADDR$, CST.CITY$, and CST.ZIP. Each field is separated by the SEP or delimiter in the default record format. You can use a CLEAR directive to reset a variable that is defined as a string template; e.g., CLEAR CST$. For more information refer to Composite Strings vs BBx Templates, IOLIST Specify Variable List, and CLEAR Reset Variables. The following example defines PRD$as a 36 character string consisting of PRD.DESC$ for 30 characters and PRD.COST for 6 digits with a scale of 2 (2 implied decimal digits):
|
||||||||||||||||||||||||||||
| Format 3 | Initialize String With Fill
Character
Use the DIM directive to define a string variable of a specific length. You can also use the DIM statement to define the value of the string variable. ProvideX uses the first character of the value you set in the char$ string as the fill character for the string being defined. The fill character is repeated for the length of the string, as follows: DIM A$(5,"*") is the same as DIM A$(5,"*-") ... both yield A$="*****" If a value is not given (or is null) then the string is initialized to spaces. Combine this string initialization with the definition of string arrays (above) to pre-initialize all the elements of a string array. For example, the DIM statement DIM ACC_IDS$[10](6,"0")defines an array of 11 strings, each pre-initialized with 6 zeroes. |
||||||||||||||||||||||||||||
| Format 4 | PxPlus provides a
structured string capability. For further details click
here.
|
||||||||||||||||||||||||||||
| Composite Strings vs BBx Templates | ProvideX
composite strings are made up of the variables you
specify in the composite string definition, whereas
string templates are strings which are parsed to obtain
the various logical variables.
This has the following impact, which you should consider
when you design applications:
|
||||||||||||||||||||||||||||