Zum Inhalt springen

CAOS-Programmierung: Befehlsgruppen: Scripts

Aus Wikibooks

Scripts

CAOS (string) inline (integer) state_trans (integer) p1 (anything) p2 (anything) commands (string) throws (integer) catches (integer) report (variable)

Executes the specified CAOS commands instantly. The local environment (_IT_ VAxx TARG OWNR etc.) will be promoted to the script's environment if  
inline is non-zero. If state_trans is non-zero, then FROM and OWNR are propogated, if zero, then the script is run orphaned. CAOS returns the output  
of the script. As you can put multiple scripts through in one call, the output is potentially concatenated. Note that all sets of scripts are  
executed  in the same virtual machine if inline is non-zero, otherwise the virtual machine is reset before each script is passed. The params _p0_ and 
_p1_ are passed in as the parameters to the script, even when inline. You can execute "outv 7 endm scrp 3 7 11 6 outv 3 endm outv 9", which will make 
a script 3 7 11 6 and return "79".
If throws is non-zero then the system will throw exceptions, otherwise it will return "***" with report set to the exception sid in the CAOS  
catalogue  TAG. If catches is non-zero then the system will catch any run errors encountered and return them in report, having set the return 
value to "###" first.

GIDS FMLY (command) family (integer)

Output the genus numbers for which there are scripts in the scriptorium for the given family. List is space delimited.

GIDS GNUS (command) family (integer) genus (integer)

Output the species numbers for which there are scripts in the scriptorium for the given family and genus. List is space delimited.

GIDS ROOT (command)

Output the family numbers for which there are scripts in the scriptorium. List is space delimited.

GIDS SPCS (command) family (integer) genus (integer) species (integer)

Output the event numbers of scripts in the scriptorium for the given classifier. List is space delimited.

INST (command)

This command indicates that the following commands should execute in a single tick - ie the script cannot be interrupted by the script 'scheduler'.  
This can be important for certain tasks which might leave an agent in an undefined (and dangerous) state if interrupted. The INST state is broken 
either manually, using a SLOW command, or implictly, if a blocking instruction is encountered (eg WAIT). Blocking instructions force the remainder of 
the script's timeslice to be discarded.

JECT (command) cos_file (string) flags (integer)

Injects a COS file from the bootstrap directory. The file is searched for (case insensitively) in all bootstrap subdirectories. You must specify the 
file extension (it doesn't have to be .cos). Flags is a combination of what you want to inject:
1 - Remove sctipt
2 - Event scripts
4 - Install script
The scripts (if present) are injected in that order. So, setting flags to 7 will fully uninstall and reinstall the cos file. Error messages and output 
are written to the current output stream.

LOCK (command)

Prevent the current script being interrupted until UNLK. Normally, events other than timer scripts interrupt (abort) currently running scripts. You 
can also use INST for similar, stronger protection.

SCRX (command) family (integer) genus (integer) species (integer) event (integer)

Remove specified script from the scriptorium.

SLOW (command)

Turn off INST state.

SORC (string) family (integer) genus (integer) species (integer) event (integer)

Returns the source code for the specified script. Use the GIDS commands to find available scripts.

SORQ (integer) family (integer) genus (integer) species (integer) event (integer)

Returns 1 if the script is in the scriptorium, or if there is a general event script for the entire genus, or family. Returns 0 if there is no 
matching script.

STOP (command)

Stops running the current script. Compare STPT.

STPT (command)

Stops any currently running script in the target agent. See also STOP.

UNLK (command)

End the LOCK section.

WAIT (command) ticks (integer)

Block the script for the specified number of ticks. This command does an implicit SLOW.