Changes a LIST formatted dynamic array into an ARRAY formatted dynamic array or vise versa.
Syntax
NewArray = SRP_Rotate_Array(Array, MajorDelim, MinorDelim)
Returns
The rotated array.
Parameters
Parameter | Description |
---|---|
Array | The dynamic array to be rotated. Required. |
MajorDelim | The delimiter that separates rows if Array is in LIST format or columns if it is in ARRAY format. Optional. If you omit this parameter, @FM will be assumed. |
MinorDelim | The delimiter that separates elements in within each column (ARRAY format) or row (LIST format). Optional. If you omit this parameter, @VM will be assumed. |
Remarks
Two dimensional dynamic arrays can be in one of two formats: LIST format or ARRAY format. The names for these formats derive from the LIST and ARRAY properties of the OpenInsight Edit Table. Both formats represent columns and rows but are delimited differently. In the LIST format, the dynamic array is first broken into rows by the major delimiter (@FM), and each element is broken into columns using the minor delimiter (@VM).
The ARRAY format takes the reverse approach. In this case, the dynamic array is first broken into columns by the major delimiter (@FM), and each element is broken into rows using the minor delimiter (@VM).
Note that in both cases, the delimiters can be any single character. Still, @FM and @VM are the most commonly used since the OpenInsight Edit Table expects those delimiters.
Fortunately, the OpenInsight Edit Table handles both formats gracefully, so it makes no real difference which format you supply. However, there are cases in which only one format is supported. For instance, V119 requires that your data be in LIST format, while the ARRAY format is usually used when storing the data in a record. Therefore, you will encounter situations in which the data will need to be converted from one format to the other. Doing this in BASIC+ is certainly possible, but it can be very slow on large datasets. SRP_Rotate_Array saves the day by performing the conversion at very high speeds.
To use it, simply pass the array you wish to rotate. If your array uses the @FM and @VM delimiters, then there is nothing else you need to do. If, however, your array uses alternative delimiters, just supply them via the MajorDelim and MinorDelim parameters. Notice that you don't need to specify the format. SRP_Rotate_Array determines the format of the given array and simply returns the array in the other format. With a single, fast call you can convert LISTs into ARRAYs and ARRAYs into LISTs.
Examples
* To show equivalency, convert an ARRAY to a LIST in an OI EditTable Array = Get_Property(@Window:".EDT_TEST", "ARRAY") List = SRP_Rotate_Array(Array) Set_Property(@Window:".EDT_TEST", "LIST", List) * Rotate a list into an array using custom delimiters List = "Don,Bakke*Paul,Simonsen*Frank,Tomeo*Bob,Fernandes*Kevin,Fournier" Array = SRP_Rotate_Array(List, "*", ",") //Array will be: "Don,Paul,Frank,Bob,Kevin*Bakke,Simonsen,Tomeo,Fernandes,Fournier"