Changes a LIST formatted dynamic array into an ARRAY formatted dynamic array or vise versa.
Syntax
NewArray = SRP_Array("Rotate", 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) |
MinorDelim | The delimiter that separates elements in within each column (ARRAY format) or row (LIST format). (OPTIONAL) |
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. The Rotate service 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. The Rotate service 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_Array("Rotate", 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_Array("Rotate", List, "*", ",") //Array will be: "Don,Paul,Frank,Bob,Kevin*Bakke,Simonsen,Tomeo,Fernandes,Fournier"