in_check script belongs to a command (which can also be a creator in a factory) and checks conditions that must be fulfilled before executing the command. Any checks depending on several input arguments can be done in this script. Moreover, any other checks not depending on input arguments, such as testing the existence of a file, are done in this script.
|To check the value of a single input argument instead of several, mutually dependant input arguments, the command input argument |
Table 19.10. Command
in_check script selector
All input arguments of the command are implicitly provided as input arguments for this script.
Moreover, if the script belongs to an object (i.e. it is defined in a type) then an additional last input argument holds a reference to the object. This argument's id is
i_object_, and its type is the type of the object.
i_object_ is used whenever the object's state must be considered in the script. For example, in case of a list, the following instruction in the
in_check script would require at least 1 item in the list, before executing the related command:
check i_object_.item_count >= 1
If the script belongs to a service then no such input argument exists.
This script always has one output argument whose id is
o_error and whose type is
void if all conditions to execute the command are fulfilled. Otherwise it returns an error describing the first check that failed.
Example 19.1. Command
in_check script example
service script_examples command append_string_twins_to_file in string1 type:string end in string2 type:string end in_check script // first we require that both strings have the same length check string1.item_count =v string2.item_count & error_message: "Both strings must be of equal length!" // we also check that file c:\foo.txt exists var file file = fa_file.create ( '''c:\foo.txt'''~ ) check v_file.exists & error_message: "File " & v_file & " must exist!" end end script // we only arrive here if no check in the 'in_check' script fails // now process data ... end end end
The implicitly defined input arguments of the above
in_check script are
i_string2 of type
string, and the implicitly defined output argument is
o_error of type
To check whether input conditions would be fulfilled in a given case, we can explicitly call the script like this:
var in_check_error error = se_script_examples.co_append_string_twins_to_file.in_check ( & string1 = "foo" & string2 = "bar" ) if v_error =r void then // everything ok else // we have a problem end if