String Array Details, Sorting Columns & Random (Web Link)

(Blox are available in the post at above link)

 

Test-Level string arrays are created so that any blox within the test can access the information contained in the string array.

 

There are a lot of uses for having a string array available so that it is available to all levels of a system. In addition, columns within the string array can be sorted independently, if needed.  This ability creates an opportunity to have a keyword index stored in a different column that can be sorted in ascending, or descending order.  By creating a keyword with an index, various index columns can be used to access data contained in other columns of the array in different sequences. Each sequence controlled by how the keyword-index is sorted and created.

 


Understanding String Size, Row and Column Count Parameters:

Trading Blox allows a maximum of 100-columns to be created.  There is also a maximum limit of 10,000 rows that can be created. Values larger than the above will generate a run-time error that will stop the script from running.

 

All String lengths in Trading Blox are limited to 512-Characters.  This is can be adjusted in String arrays so that each column can use the maximum size, or a size value that is smaller.  The only lower character limit is a size of 1-character, or a size that would safely contain the maximum number of characters you wanted to store in any of the string array's locations.  In the example provided, the maximum String size is used because the example was created to support a need to store open trade and new signal record details.

 

When creating any string array, each character will consume a character-size memory space for each element in an array.  Each row in a column of an array is a multiplier of the string size, and each column is a multiplier of the memory consumed by a column.

 

Still, memory space isn't a problem for most modern computer uses.  In the majority of cases there is more memory space than a user needs most of the time.  However, as the number of instruments in a portfolio increases, and length of data grows, at some point memory could be an issue requiring the user to reduce the number of instruments, or length of data that is being loaded.

 

In most cases most of expected string arrays aren't likely to be a memory space hog, but sizing the array's string elements should be something you think about when you make the decision so you don't make the string size larger than is needed, or create more rows and columns than are required.

 


Creating String-Array:

Once the number of row and columns, and the size of each string array element has been decided, execute the test.createStringArray method shown and if the parameters used with the method are within bounds the String-Array will be ready for use:

Example - 01:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  STRING ARRAY ROW & COLUMN SIZE DETAILS
 
'  Array Setup Parameters
StrRowLen = 512           '     512    Maximum String Length
Array_Columns = 2         '     100    Maximum Column Count
Element_Rows = 10     '  10,000    Maximum Row Count
 
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  CREATE TEST-LEVEL STRING ARRAY
Test.CreateStringArray( Array_Columns, Element_Rows, StrRowLen )

 

Storing and Retrieving String Data Information:

All arrays can be thought of as simple series of rows in a table.  In Trading Blox the standard BPV and IPV series only have 1-dimension arrays to controls the number of rows in the series.  If an Auto-Indexing series is selected, Trading Blox will handle the chore of deciding how many rows are needed, and it will also keep each row aligned to either the Instrument Date for IPV Auto-Indexed series, or it will align series rows to the test.currentDate for BPV Auto-Indexing series.

 

Trading Blox also allows manual indexing of numerical and string series to be created.  All numerical series are of TYPE: Floating and all String series are of Type String.  Numerical series will accept any decimal or integer value.  

 

Manual indexed series requires the user to determine the number rows before it is used, or to adjust the rows during use if the number of rows needed is less than the number of rows created.  Manual series also require the programmer to maintain an index that will point to, or locate a row of data where data is to be stored or retrieved.

 

All IPV and BPV series manually Index are supported by special methods for sorting and for changing the size of a manual-indexed array.  See Series topic for more complete details.

 

String Array series are a little different than Numerical series, but the need for determining how many rows are need, and the manual index tracking for each series is about the same. Sorting is also almost the same, with the exception that different methods are needed with String-Arrays, than those used with Numerical arrays.

 

Test-Level String Arrays allow  the user to create String-Type series with multiple columns. This ability can provide data isolation, or information can be linked if the order of each column is not changed, or an index reference in one column will point to a reference in a different column.

 

Test-Level String Arrays don't have a method for finding how many rows are available in the series, or for changing the count once the series is created. This means it is important to set the count for the number of rows needed accurately, or to be generous so that you won't run out of places to store information.

 

Indexing for both data types is exactly the same, but the storage and retrieval of data from a String Array element requires the use of special methods. For storing information, set the index to the next available element, and then execute the following method:

Example - 02:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  STORE DATA IN AN ARRAY ELEMENT
 
'  Send data in sTemp1 in Column 1 at Row# Ndx
Test.SetStringArrayElement( Column_1, Ndx, sTemp1 )

 

Retrieving information is requires the element-locating index to be set to the desired location and the following method executed:

Example - 03:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  RETRIEVE DATA FROM AN ARRAY ELEMENT
 
'  Get data in Column 1 at Row# Ndx, and place it in sTemp1
sTemp1 = Test.GetStringArrayElement( Column_1, Ndx)

 

Example - 04, Function:

'  Test scoped String arrays provide access to the Test-Level
'  String Table that allows a user to place, and then retrieve
'  text information into a multi-dimensional table.
 
'  To access to the global test level string arrays, use

'  the following functions and properties:
test.CreateStringArray( arrayCount, elementCount, stringLength )
 
'  To creates multiple (arrayCount) string arrays each with
'  a fixed number of elements (elementCount) and a fixed
'  string length (stringLength) for each string in the array.
test.SortStringArray( arrayIndex, direction, elementCount )
 
'  Sorts one of the string arrays (arrayIndex) using the
'  direction (1 for ascending and -1 for descending). Only
'  sorts the first elementCount number of elements in the array.
string = test.GetStringArrayElement( arrayIndex, elementIndex )
 
'  Returns a string from the arrayIndex string array at elementIndex

'  element.
test.SetStringArrayElement( arrayIndex, elementIndex, string )
 
'  Sets a string into the arrayIndex array at elementIndex element.

 

Links:

Test String Array Sorting

See Also:

Example_String_Array_Sorting Blox

 


Edit Time: 9/25/2017 09:09:58 AM


Topic ID#: 586

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software