Custom Function Parameter Index Values:

Each Parameter used in a Custom Function is given an index value.  Index values are given to each data-type that is passed into a Script-Object function.  This ability allows different types of data can be mixed in the parameters used.

 

Trading Blox Data Types:

Numeric : Any Integer, Boolean (TRUE/FALSE), Selector, or Floating value.

String: Any text value.

Series: Any Auto-Index or Manual-Index Series

 

Within a Custom-Function it is easy to get how many parameters of each data-type are available by using one or all of the following Script-Object properties:

Example:

'  Count numeric parameters
x = script.ParameterCount
'  Count String parameters
y = script.stringParameterCount
'  Count Series parameters
z = script.seriesParameterCount

 

Each of the above script parameter properties will return how many Numeric, String, and Series (Auto-Index or Manual-Index) parameters were passed into the body of a Custom Function.  Once it is known how many of each of data-type function is available each parameter can be accessed using their sequence location as their index value.

 

Parameter Counting Sequence:

Sequence of each data-type is assigned a value of 1 for the left-most parameter of each data-type up to its parameter count value as the count moves to the right.  This means each data-type will have a "1" value that increments to the count value of the right-most parameter of that data-type.

 

In this next example we have 3-numeric, 1-string, and 1-series parameters.

 

Example:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'  Method to Call the Execution of Custom Script from

'  within the script area of the calling script section.

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

'  Custom of a Mixed Parameter Function Example:
script.Execute("NumericExample", _       '  Function Name
               value1, value2, value3, _ '  3-Numeric Parameters
               sTestItem, _               '  1-String Parameter
              AsSeries(aAnySeries) )     '  1-Series Parameter
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

'  -------------------------------------------------------
'  Placed within the Custom Function's Scripting area:

'  -------------------------------------------------------
'  Parameter counts within the above function will return:
'  Count numeric parameters
PRINT "Numeric Count: ", script.parameterCount
'  Count String parameters
PRINT "String  Count: ", script.stringParameterCount
'  Count Series parameters
PRINT "Series  Count: ", script.seriesParameterCount

'  -------------------------------------------------------
 

RETURN:

Numeric Count: ,3

String  Count: ,1

Series  Count: ,1

 

Access to each of the passed parameters is available by using the access property for each data type and then using that data-type's index value location of where it is placed in the calling script list of parameters:

 

Parameter access:

'  Within Custom Function Body
NumVal1 = script.parameterList[1]           '  Numeric
NumVal2 = script.parameterList[2]           '  Numeric
NumVal3 = script.parameterList[3]           '  Numeric

 
TxtVal1 = script.stringParameterList[1]     '  STRING

 
'  x = Any known element index value
'  Incrementing an index is often done in a FOR-Loop
SeriVal[x] = script.GetSeriesValue( 1, x )   '  Series Element x

 


Edit Time: 4/6/2017 02:16:46 PM


Topic ID#: 244

 

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