- Format: arg1 = TYPE
- Called either by explicitly declaring
- "b = function(a = INT)" or
- "b = function(a)"
- Format: arg1
- Called only by specifying a value to pass
- "b = function(a)"
- Format: [arg1 = TYPE]
- Called only when needed
The single-line function usage statement is meant to be a quick reference on how to call a function. Within the parentheses are listed the arguments (or inputs) needed to properly call the function. As not all arguments are passed to the function the same way, the syntax of the argument declaration tells the user how to pass it.
Most inputs in davinci functions are davinci objects either stored in variables or created during the function call. The function usage statement will sometimes contain a declaration telling the user what type of data is expected for a specific input (in the case of explicit pass-by-reference inputs).
- BYTE - values from 0 to 255
- SHORT - values from -32768 to 32768
- INT - values from -2,147,483,648 to +2,147,483,647
- FLOAT - values from -3.402822655e+38 to +3.402822655e+38
- DOUBLE - values from
- VAL - any type of numeric value (types 1 - 5 above)
- STRUCT - a davinci structure containing specified elements
- STRING - a arbitrary length object composed of characters
- TEXT - an array of strings
Davinci objects, as arguments, may be passed by reference (explicit) or passed by value (inexplicit).
Pass by Reference
Arguments passed by reference explicitly tell the user the name of the variable as it is called and manipulated within the function (ideally it is also intuitively descriptive) followed by an "=" sign and ended with the type of data (in capital letters) that should be passed (types 1 - 9) above.
The format of a function usage statement with an explicit pass-by-reference argument looks like this:
function1(variable_name = TYPE)
An example of such a function usage statement is abs():
abs(obj = VAL)
The function abs() returns the absolute value of the given numeric davinci object of any numeric type of any three dimensions.
The user may call this function in a couple ways.
Let's take the small array of integer numbers 'a' defined below.
dv> a 5x1x1 array of int, bsq format [20 bytes] 1 -6 -4 3 8
dv> abs(obj = a) 5x1x1 array of float, bsq format [20 bytes] 1.00000 6.00000 4.00000 3.00000 8.00000
Alternatively, abs() is also capable of accepting the shorthand call:
dv> abs(a) 5x1x1 array of float, bsq format [20 bytes] 1.00000 6.00000 4.00000 3.00000 8.00000
Pass by Value
Arguments passed by value simply state a descriptive name for the variable to indicate to the user what kind of data is required. In this case, the name of the argument should not be explicitly declared when calling the function. In general, arguments passed by value are simply ordered inputs with no labels.
The format of an inexplicit pass-by-value function usage statement looks like this:
And an example:
ctof() converts a numeric array containing temperatures in celsius to fahrenheit. It doesn't have an internal variable called 'object' but rather the word 'object' attempts to describe to the user what to do. This function can only be called one way:
dv> a 124 dv> ctof(a) 255.200 dv> ctof(124) 255.200
If the user attempts an explicit variable declaration Davinci returns an error:
dv> ctof(object = a) error: Unknown keyword to ufunc: ctof(... object= ...)
By allowing some inputs to be optional, davinci has the ability to have preset values that the user doesn't need to enter for the function to work. A good example of this usage is assuming an ignore value in functions like thm.deplaid.
Optional inputs are enclosed by square brackets ( [ ] ) and defined as ususal.
For example: function(obj = VAR [, ignore = FLOAT ]) function($1 = VAR [, $2 = FLOAT ])