FreeM utility suite
Version 0.5.0.4
Library Format Specification
The format of a specification should preferably follow the MDC standard approach for the interface, e.g.
name [result] (param,...)
where
result is optional and has the form :datatype
param has the format [.]name [:[datatype] [ : optional]]
datatype is one of BOOLEAN, COMPLEX, INTEGER, MATRIX, NAME, REAL, STRING
optional is M or O
plus a description of the functionality and any error codes that are appropriate... An example from the standard is:
ABS:REAL(X:REAL,PREC:INTEGER:O)
Routines
Routine %U
Main menu for utilities - Interactive utility.
Routine %Uf
Main menu for File/Device utilities - Interactive utility.
Routine %Ufdir
File directory utility - Interactive utility.
Routine %Uflis
File Lister - Interactive utility.
Routine %Ufxxx
Not callable at the main entry point. Holds miscellaneous file/device related subroutines for the other %U utility routines.
Reads into result from device (defaults to current one). result must be defined and if non-null then this will be treated as the default value for the field, i.e. returned in the field value if the read encounters a null string.
If a length is specified then this is the maximum length allowed.
Writes text to the specified device (defaults to current one).
Prompts for and selects an output device, using params as the device parameters.
Opens device using params with timeout. Valid value for type are - "in", "out", "inout" and "new".
If the open is unsuccessful and the type is not "in" then a second attempt is made to open the device as a "new" file.
The first comma piece of the return value, if not a negative error code, is the device number/name to be used in subsequent read/write/close^%Ufxxx calls.
Routine %Ug
Main menu for Global utilities - Interactive utility.
Routine %Ugdel
Global Delete - Interactive utility.
Routine %Ugdir
Global directory utility - Interactive utility.
Routine %Ugexp
Global Export - Interactive utility.
Entry points:
Routine %Ugimp
Global Import - Interactive utility. This allows for the user to restore all globals; alternatively to selectively decide to not restore a global or restore it with a different name. ("-" = skip, "*" = restore all remaining globals, "^" = abort import.)
Entry points:
Routine %Uglis
Global Lister - Interactive utility.
Routine %Uglis2
Global Lister - Interactive utility. (Alternative version).
Routine %Ugsea
Global Search and Replace - Interactive utility.
Routine %Ugxxx
Not callable at the main entry point. Holds miscellaneous global related subroutines for the other %U utility routines.
Routine %Ur
Main menu for Routine utilities - Interactive utility.
Routine %Urdel
Routine Delete - Interactive utility.
Routine %Urdir
Routine Directory - Interactive utility.
Routine %Uredi
Routine Editor - Not callable at the main entry point.
d init^%Uredi initialises Editor. This can then be executed by x^%Ue
Routine %Urexp
Routine Export - Interactive Utility.
Routine %Urfir
Routine First Line Lister - Interactive utility.
Routine %Urimp
Routine Import - Interactive utility. This allows for the user to restore all routines; alternatively to selectively decide to not restore a routine or restore it with a different name. ("-" = skip, "*" = restore all remaining routines, "^" = abort import.)
Entry points:
Routine %Urlis
Routine Lister - Interactive utility.
Routine %Ursea
Routine Search and Replace - Interactive utility.
Routine %Urxxx
Not callable at the main entry point. Holds miscellaneous routine-related subroutines for the other %U utility routines.
Routine %Uxdat
Returns a formatted date and time. Non-interactive.
^%Uxdat(date:INTEGER:O, .format:INTEGER:O)
date defaults to the current date = $h
format defaults to 0 and has the following possible values
0 returns DD-MMM-CCYY HH:MM
1 returns CCYY-MM-DD HH:MM:SS
Returns formatted date (defaults to +$h). The format codes are the same as for ^%Uxdat()
Returns formatted time (defaults to $p($h,",",2)). The format codes are the same as for ^%Uxdat()
Routine %Uxsea
Search and Replace functions - non-interactive utility.
Routine %Uxxxx
Not callable at the main entry point. Holds miscellaneous subroutines for the other %U utility routines.
Initialises %U utility variables
Reads into result from the current device. prompt is output, subject to any language conversion. result must be defined and if non-null then this will appear between < and > after any prompt string and be treated as the default value for the field, i.e. returned in the field value if the user doesn't enter anything.
If a length is specified then this is the maximum length allowed, and may be used in any screen handling implemented (using X and Y as the location or PX and PY for the prompt location). If validation is specified then this will be executed prior to returning a result.
The following conventions are used on user input:
? = help (calls help())
@ = return null string (needed when default is specified)
^ = user abort
^^ = ^
^? = ?
^@ = @
As for read except that a newline precedes prompt.
As for readn except that the result can only be 1/0, corresponding to entering Yes/No.
Writes text to the current device at location X,Y.
As for write except that a newline precedes text.
As for writen except that text is converted using lprompt().
As for write except that format is treated as a M[UMPS] format string and precedes text.
Displays an error as a result of previous user input, converting text using lprompt() and preceding it with " - ". text starting with a "?" will not be converted.
Displays an error message, converting text using lprompt() and preceding it with "Error - ".
Returns text converted into a prompt in the appropriate user language. All text after a "-" is left unchanged and if the text contains "~" this is changed to " - " and the preceding text is also left unchanged.
Returns text with any lower case characters converted into upper case, taking into account language.
Returns text with any upper case characters converted into lower case, taking into account language.
MDC Library Routines
As part of the recent development at the MDC the concept of a M[UMPS] library was introduced, accessible from applications by using $%name^library(parameters). This could be implemented in M[UMPS] code or by the implementor in any other way, but was intended to be provided as part of the delivered M[UMPS] environment and optionally tailorable by users.
This library is provided as part of the utility package here, but needs to be accessed slightly differently since the library facility is now yet available in FreeM - by using $$name^%Ullibrary(parameters).
The library MATH is implemented as routine ^%Ulmath.
The libraries STRING and CHARACTER are implemented as a single routine ^%Ulstring.
Definitions of these can be obtained from the MDC or easily seen from the library itself.
Please note that some of these routines may require ssvns which are not currently available with FreeM.
Error numbering
All errors are negative numbers and returned in the format error,function thus allowing for calling programs to determine, if necessary, exactly where the error occurred. All calling programs should test the result of the extrinsic function and if <0 then an error has occured. Non-negative values may be used to indicate, e.g. the number of values returned, etc. Negative values should be unique throughout the utilities. The ones allocated so far are:
-1 User Abort (^ entered in read^%Uxxxx)
-102 routine not deleted in delete^%Urxxx
-103 device/file not available in open^%Ufxxx
-104 trailer invalid in ^%Urimp/^%Ugimp
-105 routine not saved in save^%Urxxx
Known errors (to be fixed)
Planned Utility Changes
Utility Development Standards
All utilities are named %U*---, where * is the type of utility (c=character, f=file/device, g=global, j=job, k=lock, l=library, n=namespace, r=routine, s=system, x=general) and --- is the name, e.g. dir for directory. All routines which are subsumed within an overall routine will have a 2 digit suffix, e.g. %Ugdir01.
All input and output will, eventually, be handled through common input/output extrinsic functions. This should allow for greater consistency and also easier language independence if so desired. The read/write %Uxxxx extrinsic functions will automatically convert these prompts into the current language setting, pulling information off ^%Uprompt(language, prompt) if it exists.
All exposed entry points should have alpha labels and be called as extrinsic functions. All internal labels should start with a %.
All routines/functions should have no other side-effects/accesses, e.g. other variables or globals, except where defined in the specification. Apart from anything else all internally used variables should be NEWed (preferably at the initial entry point). [Note: Any changes to $T or the naked reference are not considered side-effects here, but should be avoided if possible - extrinsic functions automatically restore $T anyway.]
It would be nice to have a standard usage of variable names, but ...
Standard global names should follow the routine naming standard. A standard work file (normally ^uwork($j)), which can be modified on a per UCI/namespace basis as part of the system configuration is set up when calling the initialisation module. This should be accessed in any utility using subscript indirection, e.g. @%Uwork@(...)
To allow easy modification it would be sensible for all accessing to specifically named globals, i.e. not those whose names are passed as parameters, within functions should be via name indirection in order to make them easier to change if necessary.
Jon Diamond - 1999-05-06