StrArray Class

From SysCAD Documentation
Jump to navigation Jump to search

Navigation: PGMs -> Classes -> Predefined Classes

Species Database Class Particle Size Definition Class Array Class StrArray Class Matrix Class Tag Select Class Plant Model Class Noise Class TimeClass


The String Array class allows user to Get / Set String values. Please see Array Class for getting/setting numeric values.

The StrArray (String Array) class provides member functions to create a dynamic string array and manipulate its elements.

  • The StrArray is zero indexed, i.e. the index of the first element in the StrArray is zero, and NOT 1. Therefore, the final element in a StrArray of length n will have an index = n-1.
  • If the index is out of range (length <= index) then a " PGM class execution error " will occur and the StrArray operation will be ignored.

Note: the initial length of the array is zero.

Data Members


Member Functions



Return Type



SetLen (length)

The length of the StrArray is set to the size of length

length : the required length of the StrArray, is of data type INTEGER


GetLen( )

The function returns the length of the StrArray.



x = TagGroup.GetLen()

SetAt (index, Text String)

This sets the element of the array, which corresponds to the given index to the specified Text String.

index : the index of the required entry in the StrArray (Note: index starts at zero). This is of data type, INTEGER.

Text String : the value to which the specified element, in the StrArray, will be set. This is of data type, STRING.

TagGroup.SetAt(0, "Valid SysCAD Variable Name")

GetAt ( index )

This retrieves the value (type real) of the element from the array, which corresponds to the given index.


index : the index of the required entry in the array (Note: index starts at zero). This is of data type INTEGER.

Rqd_Tag = TagGroup.GetAt(0)

SetAll (Text String)

This sets all the elements of the StrArray to the specified Text String.

Text String : the required initialising Text String. This is of data type STRING.

TagGroup.SetAll("Valid SysCAD Variable Name")


To make the StrArray variables visible in the access window the Watch command can be used.

  • Individual elements in the array can be made visible - e.g. "Watch TagGroup[2]" or "Watch [email protected][2]".
  • A range of StrArray elements can be made visible - e.g. "Watch TagGroup[All,5]" which would show the first 5 elements of the StrArray.
  • If the "@" symbol is included, then the StrArray elements will be read only fields in the access window.


Using a GetAt within a SetAt can sometimes fail.

;For example:
TagGroup.SetAt(i, TagGroup.GetAt(i+1))  ;This can sometimes fail

;The solution is to use a temporary variable to first retrieve the GetAt value and then call SetAt as follows:
STRING   TmpString
TmpString = TagGroup.GetAt(i+1)
TagGroup.SetAt(i, TmpString)


  STRING     [email protected], [email protected], [email protected], [email protected]
  LONG       [email protected]
  StrARRAY   TagGroup
  Watch TagGroup[All,5]

  Sub InitialiseSolution()
    TagGroup.SetLen(5)             ;sets the StrArray length
  Tag1 = "P_4.To (C)"
  Tag2 = "P_5.To (C)"
  Tag3 = "P_6.To (C)"

  x = TagGroup.GetLen()
  TagGroup.SetAt(0, Tag1)
  TagGroup.SetAt(1, Tag2)
  TagGroup.SetAt(2, Tag3)
  TagGroup.SetAt(4, "P_7.To (C)")
  Required_Tag= TagGroup.GetAt(1)

See also Example PGM - Species Check