fish define
command
Syntax
- fish define s ...
Define a new FISH function. The function will be named s, and must be a valid symbol name. Tokens following are assumed to be arguments that the function will take. Please see FISH Scripting Reference. [CS: this needs ‘common-izing for use with PFC] and the ref-basicclifishtutorial.`
From here until an end statement is found, FISH syntax is expected instead of standard command processing. The FISH code is parsed into a compressed format called pseudo-code, which is what is executed by the FISH runtime. Compilation errors are reported as the statements are processed.
The pseudo-code is considered part of the model state, and so is cleared on a
model new
, saved withmodel save
, and recovered withmodel restore
.The function s will be created as a global symbol if one does not already exist. If it already exists then it will be tagged as a function and the code will be executed whenever values are retrieved from it. Any function already defined on s will be deleted and overwritten.
Usage Example
The following example illustrates how fish define
can be used.
To define a simple FISH function fred that returns a value of 4.5:
fish define fred
fred = 4.5
end
To define a FISH function that takes two arguments and returns the multiplied value
fish define george(a,b)
george = a * b
end
Was this helpful? ... | 3DEC © 2019, Itasca | Updated: Feb 25, 2024 |