Write ----- (#DEFINE NON_STANDARD in omega.c to enable this, on by default). W {10,20},"OK" is the equivalent of S $X=10,$Y=20 W "OK" New --- (#DEFINE NON_STANDARD to enable this, on by default). There are two non-standard formations of NEW in oMega. 'NEW ' followed by two spaces means NEW every variable which exists. Any variables intialised after this will not be NEWed. 'NEW *' means NEW all variables which are initialised at this level or above. Existing variables are not NEWed. Thus 'NEW NEW *' would ensure that all variables are exactly as they were when leaving a function - functionally equivalent to 'NEW ()' Take care though, as 'N ' will also NEW any function paramters e.g. LABEL(X,Y) ; NEW NEW * might seem like a good idea, but of course X and Y will be NEWED too. In this case: NEW (X,Y) or NEW * is better. Pseudo Objects -------------- If OBJECT_EXTENSIONS is #DEFINEd (which is the default), the following behaviour will occur: There is now a new (additional) command syntax, > @LABEL(xxx,yyy,...) or > @LABEL starting with a single '@' and followed by two spaces. [Note this is a _command_ not a paramter] This will be interpreted by oMega as: D LABEL^objfile(xxx,yyy,...) or D LABEL^objfile respectively. Objfile here is the value of the (system) variable $OBJFILE, which is set at the current level, similar to $ZT(RAP). The default is "%OBJECTS" (or whatever we #define OBJFILE to in omega.c), so @RANDOM(100) would normally be translated to D RANDOM^%OBJECTS(100). This is a very powerful way of adding new commands: with OBJECT_EXTENSIONS defined, a program (^FOO) could look like: FOO SET $OBJFILE="MYOBJECTS" ; set OBJECT file to ^MYOBJECTS ... @READ_IN("/usr/local/test/text.txt",MYARRAY) ...etc where the routine ^MYOBJECTS has a label: READ_IN(FILE,.ARRAY) ; NEW A,X KILL ARRAY OPEN FILE USE FILE FOR X=1:1 READ A QUIT:A="" SET ARRAY(X)=A CLOSE FILE Q When the routine ^FOO is finished, $OBJECTS (variable) would resort to "%OBJECTS" or whatever it was at the next lower level. $OBJFILE could even be set before going in to ^FOO, eg. to "MYOBJECTS" or "MYOBJECTS2" depending on other variables. This would then cause any @commands in ^FOO to behave differently, e.g. per-user commands. ZE(RROR) can be used to _create_ errors in an "object file", though the line reference will point to the object file location. ADDITONALLY, if LABEL in $OBJFILE only takes a single parameter, then @LABEL xxx can be used to call it, eg. @ZS(AVE) xxx would be translated to D ZS(AVE)^%OBJECTS("xxx") (xxx is passed in as a string). with corresponding code: ZS(file) ; ZSAVE(file) ; NEW (file) ... save file differently... ... QUIT in ^%OBJECTS. Note that LABEL in the object file should always be in upper case, as @command will get translated to @COMMAND. KILL $OBJFILE will reset $OBJFILE to its default value. Aliases ------- With OBJECT_EXTENSIONS turned on, it possible to 'alias' COMMAND to @COMMAND. This means that any occurences of COMMAND will be interpreted as @COMMAND (see above 'PSEUDO OBJECTS'). The way this is done is using 'ZAL(IAS) COMMAND'. There is also an equivalent 'ZUN(ALIAS)'. ZUN without parameters will remove all zaliases. You can tell if a command is zaliased: $DATA($ZALIAS.ZS) will be 1 if ZS has been zaliased. In this way, you can also overload any of the standard M commands. They will take precedence over the builtin ones. Furthermore, zaliases remember the value of $OBJFILE _when they were set_. Thus, if a routine changes $OBJFILE, all the previous zaliases should still work. However, if you want to re-alias COMMAND after defining a new $OBJFILE, you should do something like: SET $OBJFILE="NEWFILE" ... SET REMEMBER(COMMAND)=$ZALIAS.COMMAND ; do this first ZALIAS COMMAND ... etc. ... ZUNALIAS COMMAND IF REMEMBER(COMMAND)'="" DO . SET $OBJFILE=REMEMBER(COMMAND) ZALIAS COMMAND ; set it back Q Note also that you must ZAL(IAS) both the shortened and long form of commands separately, e.g ZALIAS ZS,ZSAVE ZALIAS followed by two spaces will display all aliases currently defined. Remember, you can create aliases for any of the normal oMega commands, which will overwrite those commands (e.g ZALIAS GOTO,G) May want to ZUNALIAS that command in $OBJFILE otherwise you may get a stack error if the command repeatedly calls itself. You can alias it again before returning. ZALIASing ZUNALIAS is therefore probably a very bad idea unless you know what you are doing ! A vary useful alias, I find is this: ZALIAS EDIT,ED corresponding to sections: ED(X) ; EDIT(X) DO ^%EDIT(X) QUIT ; in $OBJFILE. 'EDIT FOO' or 'ED FOO' will now edit the file ^FOO... Tied Routines ------------- Calling oMega with a paramter e.g, oMega RTN will execute ^RTN in 'tied' mode - meaning that when ^RTN finishes or errors, we exit oMega. RTN should always come last after any switches. However, if ^RTN contains a 'ZQUIT xxx' command will go to the command line and the user will no longer be in tied mode. This is useful if you want to define some ZALIASES every time you start up oMega. E.g. Call oMega with 'oMega %INIT'. Make a routine %INIT which sets any aliases you want to use, and finishing with ZQUIT 1. Note that ZQUIT followed by two spaces (a normal ZQUIT) would does not do this, and it would throw the user out of oMega if they are in tied mode. (Non) Strict Parameters ----------------- If STRICT_PARAMETERS is not defined at compilation (it is not defined by default), then parameters passed to extrinsic functions are modified in the following ways. First, if too many parameters are passed in, an error is not produced, the extra parameters are simply ignored (not passed to the function). Second, parameters following a label can be prefixed by a '.' to show that the corresponding these parameters will be passed by reference. This means that you do not need to use a '.' when calling these functions (i.e. this is the reverse of the usual where the caller requires a '.' but the called function does not). This allows easier use of 'object files' as described above. Miscelleneous Bits ------------------ The variable '$' is always null, so you can do SET X=$ or S X=$O(A($)) for example. -------------------------------------------------------------------------------