The <class>Routine</class> class provides a way to create and manipulate routines stored within a database. More...
Public Member Functions | |
_.Library.Status | OnClose () |
This callback method is invoked by the <METHOD>Close</METHOD> method to. More... | |
_.Library.Status | Clear () |
Clear the contents of this Stream from permanent storage. More... | |
_.Library.Status | Compile (_.Library.String qspec) |
Compile this routine. More... | |
_.Library.Status | Flush () |
Flush any output in the stream not already saved. | |
_.Library.TimeStamp | GetCurrentTimeStamp () |
Get the on-disk timestamp for the routine. | |
_.Library.Numeric | GetObjectVersion () |
Returns the major.minor version number of the ObjectScript compiler that produced the object code. More... | |
_.Library.Status | Lock () |
Lock the current routine. | |
_.Library.Status | MoveToEnd () |
Move to the end of the stream so the next <METHDO>Write</METHOD> will be appended to the end. More... | |
_.Library.Status | Rewind () |
Go back to the start of the stream. | |
_.Library.Boolean | RoutineExists () |
This is an instance method which tests if this routine exists (that. More... | |
_.Library.Status | Save (_.Library.Boolean supressbackup) |
Save this routine. | |
_.Library.Integer | SizeGet () |
Return the current size of the data stream. | |
_.Library.Status | Unlock () |
Unlock the current routine. | |
![]() | |
_.Library.Status | AcquireLock (locktype) |
Acquires a lock for the current instance. More... | |
_.Library.Status | OnAfterSave (_.Library.Boolean insert) |
This callback method is invoked by the <METHOD>Save</METHOD> method to. More... | |
_.Library.Status | OnBeforeSave (_.Library.Boolean insert) |
This callback method is invoked by the <METHOD>Save</METHOD> method to. More... | |
_.Library.Status | OnOpen () |
This callback method is invoked by the <METHOD>Open</METHOD> method to. More... | |
_.Library.Status | OnReload () |
This callback method is invoked by the <METHOD>Reload</METHOD> method to. More... | |
_.Library.Status | OnRollBack () |
This callback method is invoked by the <METHOD>Save</METHOD> method to. More... | |
_.Library.Status | CopyFrom (_.Stream.Object source) |
Copies the contents of source into this Stream. More... | |
_.Library.Status | CopyFromAndSave (_.Stream.Object source) |
Copy the stream from source into the current stream ignoring anything already in the current stream. More... | |
_.Library.Integer | FindAt (_.Library.Integer position, _.Library.RawString target, _.Library.RawString tmpstr, _.Library.Boolean caseinsensitive) |
Find the first occurrence of target in the stream, starting the search at position. More... | |
_.Library.Status | InputFromDevice (_.Library.Integer len, _.Library.Integer timeout) |
Input len characters from the current device into the stream. More... | |
_.Library.Boolean | MoveTo (_.Library.Integer position) |
Move to this position in the stream. More... | |
_.Library.Status | OutputToDevice (_.Library.Integer len) |
Write out len characters of the stream to the current device starting from the current position. More... | |
_.Library.Status | OutputToDeviceAt (_.Library.Integer position, _.Library.Integer length) |
Output the stream to the current device starting at position of length. More... | |
_.Library.RawString | Read (_.Library.Integer len, _.Library.Status sc) |
Reads up to len characters from the current position. More... | |
_.Library.RawString | ReadLine (_.Library.Integer len, _.Library.Status sc, _.Library.Boolean eol) |
Read a line from the stream. More... | |
_.Library.String | ReadSQL (_.Library.Integer start, _.Library.Integer end) |
SQL specific method for reading stream data. | |
_.Library.Status | SerializeToSyncSet (_.SYNC.SyncSet ss, _.Library.Integer iPtr, _.Library.String property) |
SerializeToSyncSet copies the stream value from the current object to the sync set global. More... | |
_.Library.Status | SyncStreamIn (_.SYNC.SyncSet ss, _.Library.Integer iPtr, _.Library.String property) |
SyncStreamIn copies the stream value from the sync set global into the current object. | |
_.Library.Status | Write (_.Library.RawString data) |
Appends the string data to the stream and advances the. More... | |
_.Library.Status | WriteLine (_.Library.RawString data) |
Appends the string data along with a line terminator to the stream and advances the. More... | |
![]() | |
_.Library.Status | OnAddToSaveSet (_.Library.Integer depth, _.Library.Integer insert, _.Library.Integer callcount) |
This callback method is invoked when the current object is added to the SaveSet,. More... | |
_.Library.Status | OnConstructClone (_.Library.RegisteredObject object, _.Library.Boolean deep, _.Library.String cloned) |
This callback method is invoked by the <METHOD>ConstructClone</METHOD> method to. More... | |
_.Library.Status | OnNew () |
This callback method is invoked by the <METHOD>New</METHOD> method to. More... | |
_.Library.Status | OnValidateObject () |
This callback method is invoked by the <METHOD>ValidateObject</METHOD> method to. More... | |
![]() | |
_.Library.Status | CopyFrom (_.Stream.Object source) |
Copies the contents of source into this Stream. More... | |
_.Library.Boolean | DeleteAttribute (_.Library.String name) |
Removes this attribute variable from the collection. More... | |
_.Library.String | GetAttribute (_.Library.String name, _.Library.String default) |
Retrieves the named attribute value. | |
_.Library.String | GetStreamId () |
Returns an full id value (including class name) with which the Stream implementation has stored. More... | |
_.Library.Boolean | IsDefinedAttribute (_.Library.String name) |
Returns true if the named attribute variable exists in the collection, false otherwise. | |
_.Library.Boolean | IsNull () |
Returns true if this is a "NULL" stream; that is, a stream which has never. More... | |
_.Library.String | NextAttribute (_.Library.String name) |
Retrieves the next attribute variable name in the sequence, skip any '' names. | |
_.Library.AbstractStream | ReadLineIntoStream () |
This reads from the stream until it find the <property>LineTerminator</property> and returns. More... | |
_.Library.Status | SaveStream () |
Deprecated method, use <method>Save</method> instead. More... | |
SetAttribute (_.Library.String name, _.Library.String value) | |
Inserts an attribute variable by name into the collection. | |
_.Library.Status | WriteLine (_.Library.RawString data) |
Appends the string data along with a line terminator to the stream and advances the. More... | |
Static Public Member Functions | |
_.Library.Boolean | CheckProtect (_.Library.String name) |
Check if we are allowed to save this routine in this namespace. | |
_.Library.Status | CheckSyntax (_.Library.String Source, _.Library.String Errors, _.Library.Integer LanguageMode) |
This function syntax checks INT source code. More... | |
_.Library.Status | CompileAll (_.Library.String Flags, _.Library.String IO, _.Library.Integer Count, _.Library.Integer Errors, _.Library.Integer MultiCompile, _.Library.Integer Journal, _.Library.Boolean KeepSource) |
Compile all routines in a namespace. More... | |
_.Library.Status | CompileAllNamespaces (_.Library.String Flags, _.Library.String IO, _.Library.Integer Count, _.Library.Integer Errors, _.Library.Integer MultiCompile, _.Library.Integer Journal, _.Library.Boolean KeepSource) |
Compile all routines in all namespace. More... | |
_.Library.Status | CompileList (_.Library.String rtns, _.Library.String qspec) |
Compile a list of routines in the current namespace. More... | |
_.Library.Status | CompileSelected (_.Library.String Mask, _.Library.String Flags, _.Library.String IO, _.Library.Integer Count, _.Library.Integer Errors, _.Library.Integer MultiCompile, _.Library.Integer Journal, _.Library.Boolean KeepSource) |
Compile selected routines in a namespace. More... | |
_.Library.Status | Delete (_.Library.String rtnname, _.Library.String flag, _.Library.Boolean supressbackup, _.Library.String nsp) |
Delete the routine rtnname. More... | |
_.Library.Boolean | Exists (_.Library.String name) |
This is a class method which tests if the routine name exists. More... | |
_.Library.TimeStamp | GetDate (_.Library.String name) |
Return the timestamp the routine with name was last updated. | |
_.Library.Status | GetRoutineGlobals (_.Library.String Names) |
Return list of globals where routine and class information is stored. More... | |
_.Library.Status | LockRoutine (_.Library.String name, _.Library.Boolean lock, _.Library.String nsp, _.Library.Boolean IModeLock, _.Library.Integer timeout) |
Lock a particular routine <parameter>name</parameter>. More... | |
_.Library.Status | RoutineListFetch (_.Library.Binary QHandle, _.Library.List Row, _.Library.Integer AtEnd) |
Fetch returns the next row in the query. | |
_.Library.Status | RoutineListFetchRows (_.Library.Binary QHandle, _.Library.Integer FetchCount, _.Library.List RowSet, _.Library.Integer ReturnCount, _.Library.Integer AtEnd) |
RoutineListFetchRows returns the next FetchCount rows in the query. | |
_.Library.Status | RoutinesSortByFieldFetch (_.Library.Binary QHandle, _.Library.List Row, _.Library.Integer AtEnd) |
Fetch returns the next row in the query. | |
_.Library.Status | RoutinesSortByFieldFetchRows (_.Library.Binary QHandle, _.Library.Integer FetchCount, _.Library.List RowSet, _.Library.Integer ReturnCount, _.Library.Integer AtEnd) |
RoutineListFetchRows returns the next FetchCount rows in the query. | |
![]() | |
_.Library.String | GetLockReference (_.Library.String pLocation, _.Library.String pId) |
Returns the global reference used to lock the current stream object. More... | |
_.Library.Status | OnDelete (_.Library.ObjectIdentity oid) |
This callback method is invoked by the <METHOD>Delete</METHOD> method to. More... | |
_.Library.String | IsCharacter () |
Return true if this is a character stream and false if it is a binary stream. | |
_.Library.Boolean | StreamOIDIsNull (_.Library.ObjectIdentity soid) |
Return true if this stream oid is a null stream and false if the stream is not null. | |
![]() | |
_.Library.Status | DeleteStream (_.Library.ObjectIdentity oid, _.Library.Integer concurrency) |
Deprecated method, use <method>Delete</method> instead. More... | |
Public Attributes | |
Generated | |
True if this routine is generated from something else. More... | |
IsModified | |
More... | |
LanguageMode | |
The language mode of this routine. More... | |
Locked | |
Number of times this routine has been locked. More... | |
Name | |
The name (without extension) of the routine associated with this object. More... | |
Namespace | |
Return the namespace this routine is from. More... | |
RoutineName | |
The name of the routine. More... | |
RoutineType | |
The type of the routine. More... | |
RoutineVersion | |
More... | |
TimeStamp | |
More... | |
UpToDate | |
For INT routines if this is compiled from a MAC then return true if the INT. More... | |
![]() | |
AtEnd | |
The AtEnd property is set to true (1) when, during a read,. More... | |
LastModified | |
LastModified is a read-only property containing the <class>TimeStamp</class> of More... | |
Size | |
Size is a read-only property containing the current size of the stream (in bytes More... | |
![]() | |
Attributes | |
An array of strings containing any attribute values associated with this stream. More... | |
LineTerminator | |
Type of line terminator we use for this stream, defaults to Cr/Lf. More... | |
Private Member Functions | |
_.Library.Integer | IsModified () |
Returns true (1) if a property of this instance has been modified, otherwise false (0). More... | |
_.Library.Integer | ObjectModified () |
This method is somewhat similar to IsModified but it also checks to see if swizzled. More... | |
_.Library.String | __BuildRoutineName () |
Return the complete routine name for this routine. | |
_.Library.String | __IOGetStreamId () |
Return the id for a stream; that is, an identifier that can later be used. More... | |
__IOInit () | |
Initialize member variable used by the StreamAdaptor. More... | |
_.Library.Status | __ParseRoutineName (_.Library.String name) |
Split a routine name into its components; set the name,type etc. More... | |
_.Library.Boolean | __ReadIntoBuffer () |
Reads the next node into Buffer. More... | |
Private Attributes | |
__Buffer | |
More... | |
__IOLangMode | |
More... | |
__IOLines | |
More... | |
__IOSize | |
More... | |
__NodeNo | |
The current node we are reading from. More... | |
__Position | |
More... | |
__StoreGlvn | |
More... | |
__TempNode | |
More... | |
Additional Inherited Members | |
![]() | |
DEFAULTCONCURRENCY = None | |
![]() | |
CAPTION = None | |
Optional name used by the Form Wizard for a class when generating forms. More... | |
JAVATYPE = None | |
The Java type to be used when exported. | |
PROPERTYVALIDATION = None | |
This parameter controls the default validation behavior for the object. More... | |
![]() | |
MAXLEN = None | |
The maximum number of characters (or bytes) allowed in a stream. | |
PROPERTYVALIDATION = None | |
Turns off property validation. | |
The <class>Routine</class> class provides a way to create and manipulate routines stored within a database.
The <class>Routine</class> class provides a stream interface (see <class>AbstractStream</class>) that allows you to read existing routines as well as create new one programmatically.
<class>Routine</class> includes methods to save and compile modified routines.
For example, the following code creates, saves, and compiles a simple ObjectScript routine (note that lines of code start with a space character):
Set routine = ##class(Routine).New("MyRoutine.MAC")
; Write lines of code to the routine Do routine.WriteLine("MyRoutine") Do routine.WriteLine("Tag()") Do routine.WriteLine(" Write ""This is my routine"",!") Do routine.WriteLine(" Quit")
; save the routine Do routine.Save()
; compile the routine Do routine.Compile()
|
private |
Returns true (1) if a property of this instance has been modified, otherwise false (0).
A TRUE result does not necessarily mean that any property has actually been changed. If IsModified() returns false then the object has not been modified. There are some situations where we simply cannot efficiently detect a change in value. In these cases we will set the modified status of the property.
Reimplemented from AbstractStream.
|
private |
This method is somewhat similar to IsModified but it also checks to see if swizzled.
references would cause the object to become modified should they be serialized. This works on the assumption that a reference to a persistent object will never be modified if the ID has already been assigned. For references to serial objects, a call to ObjectModified indicates whether or not the serialized value is different. If the reference to a swizzled object is different from the initial object state then the $$$objModAll macro will already return true. Reference the <property>Set code.
Returns true (1) if this instance has been modified, otherwise false (0).
Reimplemented from AbstractStream.
_.Library.Status OnClose | ( | ) |
This callback method is invoked by the <METHOD>Close</METHOD> method to.
provide notification that the current object is being closed.
The return value of this method is ignored.
Reimplemented from AbstractStream.
|
static |
This function syntax checks INT source code.
Source - source (INT) code; either a single line stored in a variable, or an array where: array(0)=#lines, array(1-n)=source
Errors (byref) - Returned array of errors detected by compiler
LanguageMode - language mode, 0-10 (optional, default 0)
_.Library.Status Clear | ( | ) |
Clear the contents of this Stream from permanent storage.
This will remove the permanent stream storage and
any temporary stream and initialise the stream to its initial state that it starts in, including removing all the stream attributes.
Returns a <CLASS>Status</CLASS> value indicating success or failure.
Reimplemented from Object.
_.Library.Status Compile | ( | _.Library.String | qspec | ) |
Compile this routine.
For information on qSpec, see System Flags and Qualifiers.
|
static |
Compile all routines in a namespace.
This method will compile all routines in the current namespace.
Flags Bit string of options to method.
Bit 0 - Suppress syntax error display.
Bit 1 - Suppress output to principal device.
IO Already open device to send the output to. For example, "c:\a.out"
Count (by ref) Number of routines compiled.
Errors (by ref) Number of routines with syntax errors.
MultiCompile - If true then use multiple jobs to do the compile, if not specified use the default /multicompile qualifier setting
Journal - If true then journal the compile, if false disable journaling for compile, if not specified use the default /journal qualifier setting
KeepSource - If true (default) then keep INT code from compiling a MAC, if false then do not save INT code
|
static |
Compile all routines in all namespace.
This method will compile all routines in all namespaces. This will not compile routines in SYSTEM defined namespaces.
Flags Bit string of options to method.
Bit 0 - Suppress syntax error display.
Bit 1 - Suppress output to principal device.
IO Already open device to send the output to. For example, "c:\a.out"
Count (by ref) Number of routines compiled.
Errors (by ref) Number of routines with syntax errors.
MultiCompile - If true (default) then use multiple jobs to do the compile
Journal - If true (default) then journal the compile, if false disable journaling for compile
KeepSource - If true (default) then keep INT code from compiling a MAC, if false then do not save INT code
|
static |
Compile a list of routines in the current namespace.
Pass this a comma separated list of items, which can include wild card characters e.g. 'test.mac,abc*.int' or pass in a subscripted array with the routine name as the subscript. It will return an error Status. If you do not wish to use multicompile then pass in /multicompile=0
|
static |
Compile selected routines in a namespace.
Mask Selection mask of which routines to compile. This mask is passed to Library.Routine.RoutineList() and must be in a format it understands.
Flags Bit string of options to method.
Bit 0 - Suppress syntax error display.
Bit 1 - Suppress output to principal device.
IO Already open device to send the output to. For example, "c:\a.out"
Count (by ref) Number of routines compiled.
Errors (by ref) Number of routines with syntax errors.
MultiCompile - If true then use multiple jobs to do the compile, if not specified use the default /multicompile qualifier setting
Journal - If true then journal the compile, if false disable journaling for compile, if not specified use the default /journal qualifier setting
KeepSource - If true (default) then keep INT code from compiling a MAC, if false then do not save INT code
|
static |
Delete the routine rtnname.
If the rtnname is not fully qualified we will resolve this into
a fully qualified name first and then proceed with the rest of the delete. For example if you specify 'test' and there is a 'test.mac' it will resolve to this, if there was only a 'test.obj' it will resolve the name to this. The parameter flag specifies how much to delete. The options are:
This returns a Status code to show if it worked or not. If you pass a name like 'test.mac;*' it will delete all backup versions of this routine. If the routine name which is passed does not exists, the method will return success.
|
static |
This is a class method which tests if the routine name exists.
If name consists of a routine name and an extension, such as INT, MAC, etc. then it will check for this specific routine. If it just contains the routine name it will check if either MAC, INT, or BAS exists.
Write ##class(Routine).Exists("Test.MAC") Write ##class(Routine).Exists("Test")
_.Library.Numeric GetObjectVersion | ( | ) |
Returns the major.minor version number of the ObjectScript compiler that produced the object code.
for this routine. Returns 0 if there is no object code for the routine.
|
static |
Return list of globals where routine and class information is stored.
Returns Names="ROUTINE,rBACKUP,rINC,rINCSAVE,rINDEX,rMAC,rMACSAVE,rMAP,rOBJ,oddDEF"
Here is some documentation on the format of the routine globals.
ROUTINE - Native .INT COS code, generated from .MAC, or generated from classes. When compiled generates .OBJ code.
ROUTINE(Name,0)=timestamp when last saved
ROUTINE(Name,0,0)=# lines in routine
ROUTINE(Name,0,1...x) = Source Lines in routine
ROUTINE(Name,0,"GENERATED")= 0/1 whether routine is generated or native
ROUTINE(Name,0,"INC",IncludeFileName1)=Timestamp when last include file last saved
ROUTINE(Name,0,"INC",IncludeFileName2)=Timestamp when last include file last saved
ROUTINE(Name,0,"SIZE")=# bytes in routine
ROUTINE(Name,0,"LANG")=language mode<br>
ROUTINE(Name,"MAC")=Timestamp of .MAC code when last saved if generated
rBACKUP(Name,Type,version) - backup of ^ROUTINE, created by the command Merge ^rBACKUP(rtn,type,nextverersion)=^ROUTINE(rtn) where type="INT/MVI/BAS"
rINC - Native .INT or macro code, compiled into .MAC when included with #include directive
rINC(Name,0)=timestamp when last saved
rINC(Name,0,0)=# lines in include file
rINC(Name,0,1...x) = Source Lines in include file
rINC(Name,0,"SIZE")=# bytes in include file
rINC("ZZ","P") - Meta data used for precompiling include files<br>
rINCSAVE - Backup of ^rINC, created by the command Merge ^rINCSAVE(rtn,nextver)=^rINC(rtn,0)
rINDEX - Index of .OBJ, .INT, and .MAC routines
rINDEX(Name,"OBJ/MAC/INC")=$lb(Time compiled,Size)
rINDEX(Name,"INT")=$lb(Time compiled,Size,Generated 0/1)
rMAC - Native .MAC Macro code which when compiled generates .INT code
rMAC(Name,0)=Timestamp when last saved
rMAC(Name,0,0)=#lines in routine
rMAC(Name,0,1...x) = Source Lines in routine
rMAC(Name,0,"SIZE")=# bytes in routine<br>
rMACSAVE(Name,Type,version) - backup of ^rMAC, created by the command Merge ^rMACSAVE(rtn,nextver)=^rMAC(rtn,0)
rMAP - Debug map used by the debugger and for error trapping
rMAP(Name,"INT","MAC",offsets)=$lb(debuginfo)
rMAP(Name,"MAC","INT",offsets)=$lb(debuginfo)
rOBJ - Compiled .INT code
rOBJ(Name,"INT")=timestamp of .INT code when compiled
rOBJ(Name,0...n)=Compiled object code<br>
oddDEF - Source code for classes
oddDEF($zcvt(Name,"U"),....)=source code from class. Note that all of the other odd* nodes are meta data describing the class, and can be recreated by compiling the class. The rINDEXCLASS and rINDEXSQL nodes also get recreated when compiling the class.
|
private |
Return the id for a stream; that is, an identifier that can later be used.
to open the same stream.
Reimplemented from AbstractStream.
|
private |
Initialize member variable used by the StreamAdaptor.
This
This is called when the containing stream is opened via SetSerial.
Reimplemented from AbstractStream.
|
static |
Lock a particular routine <parameter>name</parameter>.
If <parameter>lock</parameter> is true (the default)
then it locks the routine, and if false then it unlocks the routine. If a routine is derived from a class then it will lock the class name in ^oddDEF to prevent another user from attempting to edit the class at the same time this process is editing the routine. If IModeLock is True, then it will unlock the routine with the #I flag so that the node will unlock even if in a transaction.
_.Library.Status MoveToEnd | ( | ) |
Move to the end of the stream so the next <METHDO>Write</METHOD> will be appended to the end.
This allows you to read from a stream, then MoveToEnd() and append new data, where just calling <METHOD>Write</METHOD> after a read will clear the stream before writing new data.
Returns a <CLASS>Status</CLASS> value indicating success or failure.
Reimplemented from AbstractStream.
|
private |
Split a routine name into its components; set the name,type etc.
If name has no extension, then the default is .MAC.
|
private |
Reads the next node into Buffer.
Returns 0 if there is no more data.
_.Library.Boolean RoutineExists | ( | ) |
This is an instance method which tests if this routine exists (that.
is, it has been saved to disk).
|
private |
Generated |
True if this routine is generated from something else.
|
private |
|
private |
|
private |
IsModified |
LanguageMode |
The language mode of this routine.
Locked |
Number of times this routine has been locked.
The name (without extension) of the routine associated with this object.
This is for backwards compatibility only.
Namespace |
Return the namespace this routine is from.
|
private |
The current node we are reading from.
|
private |
RoutineName |
The name of the routine.
RoutineType |
The type of the routine.
RoutineVersion |
|
private |
|
private |
UpToDate |
For INT routines if this is compiled from a MAC then return true if the INT.
is up to date with the MAC, but if the INT is different to the MAC, e.g. it was modified and saved directly or the MAC was modified and saved but not compiled then it will return false.
For MAC routines it will be true if the generated pcode from compiling this MAC is up to date and false if recompiling this MAC would generate different pcode, so either the MAC has changed or the pcode has changed.