...
Do vytvoreného bloku sa parametre pridávajú jedným alebo viacnásobným volaním funkcie funkcií EDA_AddBlockParameters, EDA_AddBlockParameterVector a EDA_AddBlockParameterVectors. Naplnený blok parametrov je možné použiť vo funkciách, ktoré podporujú blok parametrov, ako napr. EDA_ReadValuesFromVektorRec alebo EDA_CalcFunctionRec. Keď už blok parametrov nie je potrebný, je ho potrebné odstrániť volaním funkcie EDA_DestroyParameterBlock.
...
Príklad použitia:
BEGIN
INT _errorCode
TEXT _funcBody
TIME _bt, _et
RECORD NOALIAS (SD.EDA_Arr_Obj) _paramNames, _paramValues, _data
RECORD NOALIAS (SD.EDA_CalcFunction_Params_V1) _calcParams
|
|
; vytvorí blok parametrov
CALL %EDA_CreateParameterBlock(_paramBlockId, _errorCode)
IF _errorCode != 0 THEN
RETURN
ENDIF |
|
; vlozi jednoduche parametre do bloku
REDIM _paramNames[4]
|
|
;REDIM _paramValues[4]
_paramNames[1]^val := "_paramBool"
_paramValues[1]^val := @TRUE
_paramNames[2]^val := "_paramInt"
_paramValues[2]^val := 2
_paramNames[3]^val := "_paramReal"
_paramValues[3]^val := 3.5
_paramNames[4]^val := "_paramTime"
_paramValues[4]^val := %TimeFromItems(2015, 1, 1, 0, 0, 0, 0)
CALL %EDA_AddBlockParameters(_paramBlockId, _paramNames, _paramValues, _errorCode)
IF _errorCode != 0 THEN
RETURN
ENDIF
|
|
; vlozi vektorovy parameter |
|
REDIM _paramNames[1]paramNames[1]^val := "_paramVector"
_paramValues[1]^val := 4.0 TIME %TimeFromItems(2015, 1, 1, 0, 0, 0, 0)
_paramValues[2]^val := 5.0 TIME %TimeFromItems(2015, 1, 1, 1, 0, 0, 0)
CALL %EDA_ |
|
AddBlockParametersAddBlockParameterVector(_paramBlockId, |
|
_paramNames[1]^val"_paramVector", _paramValues, _errorCode)
IF _errorCode != 0 THEN
RETURN
|
|
; vlozi strukturovany parameter
REDIM _ |
|
paramNames[1]
REDIM _paramNames[1]^val := "_paramVectors"
_paramValues[1]^val := 6
_paramValues[2]^val := 7
_paramValues[3]^val := 8
_paramValues[4]^val := 9
_paramValues[5]^val := 10
_paramValues[6]^val := 11
CALL %EDA_ |
|
AddBlockParametersAddBlockParameterVectors(_paramBlockId, |
|
_paramNames[1]^val"_paramVectors", _paramValues, _errorCode)
IF _errorCode != 0 THEN
RETURN
ENDIF
; zavola vypocet funkcie, kde pouzije zadane parametre
_calcParams[1]^structVersion := 1
_calcParams[1]^paramBlockId := _paramBlockId
_bt := %TimeFromItems(2015, 1, 1, 0, 0, 0, 0)
_et := _bt
_funcBody := "VEKTOR _v;" + %Chr(10)
_funcBody := _funcBody + "PARAM BOOL _paramBool;" + %Chr(10)
_funcBody := _funcBody + "PARAM INT _paramInt;" + %Chr(10)
_funcBody := _funcBody + "PARAM REAL _paramReal;" + %Chr(10)
_funcBody := _funcBody + "PARAM TIME _paramTime;" + %Chr(10)
_funcBody := _funcBody + "PARAM VEKTOR _paramVector;" + %Chr(10)
_funcBody := _funcBody + "PARAM VEKTORS _paramVectors;" + %Chr(10)
_funcBody := _funcBody + "%CreateVektor(_v, 1);" + %Chr(10)
_funcBody := _funcBody + "%SetItemTime(_v, 1, _paramTime);" + %Chr(10)
_funcBody := _funcBody + "_v[1] := _paramBool + _paramInt + _paramReal + _paramVector[1] + _paramVector[2] + %ValuesNr(_paramVectors);" + %Chr(10)
_funcBody := _funcBody + "RETURN _v;"
CALL %EDA_CalcFunctionRec(10, _funcBody, _bt, _et, 0, _calcParams, _data, 1, _errorCode)
IF _errorCode != 0 | _data[1]^val != 21.5 THEN
RETURN
ENDIF
; zrusi blok parametrov
CALL %EDA_DestroyParameterBlock(_paramBlockId, _errorCode)
IF _errorCode != 0 THEN
RETURN
ENDIF
END |
|