function modify
A function allows you to define a new function in terms of an Adams View expression. The function modify command allows you to modify an existing user written function.
You may reverse this modification at a later time with an UNDO command.
Format:
function modify |
|---|
function_name = | existing expr_function |
new_function_name = | new expr_function |
text_of_expression = | string |
argument_names = | string |
type = | result_type |
comments = | string |
category = | func_category |
Example:
! Already have a function named "This"
VARIABLE CREATE VARIABLE_NAME=Example REAL_VALUE=(This(1))
FUNCTION MODIFY FUNCTION_NAME=This NEW_FUNCTION_NAME=That
LIST_INFO VARIABLE VARIABLE_NAME=Example
! You will see that the real value is (That(1))
Description:
Parameter | Value Type | Description |
|---|
function_name, | Existing Expr_function | Specifies the name of the user-written function you are modifying. You should choose a name which is meaningfully related to the operation that the function is performing. |
New_function_name | New Expr_function | Allows you to change the name of an already existing function. When you change the function's name, all references to it also change. |
text_of_expression, | String | The TEXT_OF_EXPRESSION parameter defines the computation to be performed by the function. |
argument_names | String | The ARGUMENT_NAMES parameter allows you to specify the names of the formal arguments in your function. |
type | Array, Integer, Location_orientation, Object, Real, String | The TYPE parameter of a function indicates the type of the returned value. |
omments | String | The COMMENTS parameter allows you to add comments to the function for documentation purposes. The strings are stored in the database and written to command files. |
category | User, String, Math, Modelling, Loc_ori, Matrix_array, Database_object, Misc | Specifies which category this function should be classified under. |
Extended Definition:
1. Remember that the value of the argument “text_of_expression” should be a character string, NOT an expression.
FUNCTION CREATE FUNCTION_NAME=SSQDIF &
ARGUMENT_NAMES=Array1, Array2 &
TEXT_OF_EXPRESSION="SSQ(Array1-Array2)" &
COMMENT_STRING="Compute sum of squares of differences between arguments" &
TYPE=real
2. The argument_names you specify are associated by position with the actual arguments when you invoke the function.
Using the following as an example:
FUNCTION CREATE FUNCTION_NAME=MyFunc ARGUMENT_NAMES=Arg1, Fred &
TEXT_OF_EXPRESSION="sqrt(Fred) * Arg1"
VARIABLE CREATE VARIABLE_NAME=TestVariable &
REAL_VALUE=(MyFunc(1+1, 9) + 4)
The first formal argument "Arg1" is associated with the value 2 (computed from 1+1); the second argument "Fred" is associated with the value 9. The resulting value for "TestVariable" is sqrt(9) * 2 + 4 = 10.