Undocumented Syntax

Functions
src = array of source code lines lm = language mode err = $list of error messages object = array of generated object code map = array of additional information about the compiled output returns 0 if no errors, 1 if errors NB all arguments are implicitly passed by reference.
 * $compile(src,lm,err,object,map)	Compiles source code in src array and outputs to object
 * $normalize(var,n)	Arithmetically rounds var to n decimal places
 * $isvalidnum(value)	Returns 1 if value is a valid number (can be non-canonical eg 001.00100)

$ZUTIL Functions
a is threshold for wdqsize b is max wait when wdqsize is < a			  c is max wait when wdqsize is >= a			   d is min wait
 * $zu(25,processId,0,sessionId) Attaches to a process for debugging
 * $zu(25,processId,1)   Interrupts an attached process and puts it in break mode
 * $zu(25,processId,2)   Detaches from a process being debugged
 * $zu(40,0,0)		Endian flag? or something to do with ascii/ebcedic or similar?
 * $zu(40,0,1)           sizeof(long), ILEN
 * $zu(40,0,3)           sizeof(char*), CPLEN
 * $zu(40,0,4)           sizeof(void*), PPLEN
 * $zu(40,0,5)           GFOFFSET
 * $zu(40,0,6)           BLTYPE
 * $zu(40,0,7)           BLOFF
 * $zu(40,0,8)           MAPLABEL
 * $zu(40,0,9)           BLLNK
 * $zu(40,0,10)          BLENGTH
 * $zu(40,0,25)		Shared memory? %ShmObj
 * $zu(40,1,n)           Offsets of various partition data (partoff)
 * $zu(40,1,0)           Something to do with ALLLOC
 * $zu(40,1,1)           offset to rouname in partition
 * $zu(40,1,2)           offset to PJourn
 * $zu(40,1,3)           offset to UIC
 * $zu(40,1,4)           offset to PID
 * $zu(40,1,5)           offset to VBUF
 * $zu(40,1,6)           offset to Plines
 * $zu(40,1,7)           offset to Pobject
 * $zu(40,1,8)           offset to Pribas
 * $zu(40,1,9)           offset to Priusr
 * $zu(40,1,10)          offset to Pricur
 * $zu(40,1,11)          offset to GlobVec
 * $zu(40,1,12)          Something to do with GVO
 * $zu(40,1,13)          offset to database DIR
 * $zu(40,1,16)          offset to OP (object pointer)
 * $zu(40,1,17)          offset to DEV
 * $zu(40,1,18)          offset to PRIN
 * $zu(40,1,19)          offset to UNAME
 * $zu(40,1,20)          offset to MTBUF
 * $zu(40,1,24)          offset to ZChild/ZParent
 * $zu(40,1,26)          offset to BaseP
 * $zu(40,1,27)          offset to ProcIO
 * $zu(40,1,28)          offset to Proc$X/$Y
 * $zu(40,1,31)          offset to sortbegin buffer size (default apparently 1024): View $zutil(40,1,31):-1:1:sortsize
 * $zu(40,2,n)           Offsets of various common data (mcomoff)
 * $zu(40,2,0)           offset to PV
 * $zu(40,2,7)           JRNTYP
 * $zu(40,2,11)          SYPNTR
 * $zu(40,2,16)          LOCKTAB
 * $zu(40,2,18)          offset to GPROTDEF
 * $zu(40,2,10)          offset to Job10SW
 * $zu(40,2,21)          Something to do with BDBO
 * $zu(40,2,72)          REPTYP
 * $zu(41                Number of entries in frame-stack
 * $zu(41,frame)		typeOfCall^entryRef^... ?
 * $zu(41,frame,variable)	Frame-stack level at which variable was instantiated
 * $zu(42,frame,variable)	$order through variables at given frame-stack level
 * $zu(43,frame,variable)	Actual value of variable at specified frame-stack level
 * $zu(54,0)		get host name
 * $zu(54,1,addr)		inet_addr convert dotted-decimal to inet addr
 * $zu(54,2,binadr)	inet_ntoa convert inet addr to dotted decimal
 * $zu(54,3,binadr)	ntohl(l) convert net format to host format
 * $zu(54,4,binadr)	htonl(l) convert host format to net format
 * $zu(54,10,i)		sethostent(i)
 * $zu(54,11)		endhostent
 * $zu(54,12)		gethostent
 * $zu(54,13,name)		gethostbyname(name)
 * $zu(54,14,inadr)	gethostbyaddr(in)
 * $zu(54,20,i)		setservent(i)
 * $zu(54,21)		endservent
 * $zu(54,22)		getservent
 * $zu(54,23,name,proto)	getservbyname(name,proto)
 * $zu(54,24,port,proto)	getservbyport(port,proto)
 * $zu(56,5)             returns the method or property name and class name associated with the most recent class-related error, such as a  error.
 * $zu(59)              , ,<1 if cluster master/0 if not>,<1 if cluster is in recovery/0 if not>,<1 - always 1 on vms>, ,<# of root locks used for database block locks>,
 * $zu(67,2,$j)          Process vector
 * $zu(67,11,$j)		Returns current username (as documented)
 * $zu(67,11,newName,$j)	SETs username to newName.
 * $zu(78,26)		Number of journal files used since last Cache restart
 * $zu(79,1)	       Write daemon wake up settings:  returns a^b^c^d where
 * $zu(79,1,a,b,c,d)     Sets values for a b c d from $zu(79,1)
 * $zu(90,0)		Number of entries in globmap table - in memory version of ^SYS("GREDIR","NSINIT",ns,"globmap",g)
 * $zu(90,2,0,i)		globmap table: namespace
 * $zu(90,2,1,i)		globmap table: global name
 * $zu(90,21,namespace,global) returns server name and database location of global in namespace (ie where is the global mapped to?). NB server name is truncated to 10 characters!
 * $zu(95,num,onoff)     set/clear switch #num systemwide
 * $zu(96,0,15)		Something to do with allocating space in the symbol table
 * $zu(96,18,0)		Returns IO type of current device (eg RAW)
 * $zu(96,18,2,table)	Sets IO type of current device
 * $zu(99,0,unixtime)    Converts unixtime to horolog
 * $zu(105)              zusockfun
 * $zu(115,1)		SQL AutoCommit mode setting (per process). See Documatic entry for %SYSTEM.SQL.SetAutoCommit, and SQL doc for SET TRANSACTION %COMMITMODE
 * $zu(115,2)		SQL isolation mode (per process). 0=Read Uncommitted; 1=Read Committed. See SQL doc for SET TRANSACTION ISOLATION LEVEL
 * $zu(115,4)		Systemwide SQL lock timeout (for this process and all processes started subsequently). See Documatic entry for %SYSTEM.SQL.SetLockTimeout
 * $zu(115,9)		Should Object operations (e.g. %Save, %Delete) use TSTART/TCOMMIT? 0=no; 1=yes (default). Setting is per-process.
 * $zu(115,10)		Default concurency mode for Object operations. 0=No Locking; 1=Atomic; 2=Shared; 3=Shared/Retained; 4=Exclusive. Setting is per-process.

Opens a window on the screen. Actually, writes the contents of a rectangular area to a buffer stack erases the area and then sets smooth scrolling in that region.
 * $zu(119,key)		Send string set by $zu(120,key,string) to current device (equivalent to write $zu(120,key))
 * $zu(119,4)		Screen refresh
 * $zu(119,5)		Send init string
 * $zu(119,33,8)		Something to do with wide characters?
 * $zu(119,50,0)		Set DTM mode
 * $zu(119,50,-1)		Unset DTM mode
 * $zu(119,51,-1,top,left,height,width,e,f,g,h,i,7,0,7,0)
 * $zu(119,52)		Restores the contents of a rectangular area from a buffer stack.
 * $zu(119,54,c+1,l+1,w,h,b,a,ba,$g(cap,""),$g(cpo,""),255,255,255,255) Draws a box
 * $zu(119,56,x1+2,y1+2,x2,y2,border,$g(battr,""),$g(cap,""),$g(cpos,""),-1,255,255,255,255,$g(lrtb,"1111")) Box inside a frame
 * $zu(119,57,x1+1,y1+1,a,b,$g(c,32),255,255) Fill a rectangular area
 * $zu(119,59,f+1,l+1,n)	Scroll up
 * $zu(119,60,f+1,l+1,n)	Scroll down


 * $zu(120,key,string)	Set or returns string from allocated symbol table space (1<key<100)
 * $zu(120,40,cup)		Escape sequence for cUp


 * $zu(120,77,height)	Hight of screen
 * $zu(120,78,width)	Width of screen
 * $zu(120,79,flags)	Set some flags
 * $zu(120,80)		Terminal type table loaded
 * $zu(120,100,bytes)	Allocates space from the symbol table, returns amount of space allocated (used with $zu(96,0,15))

Valid values for p1..p8 are: 1 - Host Name - $zu(110) 2 - NameSpace name - $zu(5) 3 - Config name - $zu(86) 4 - Current time 5 - pid 6 - Username 7 - Time executing last command (in seconds.milliseconds)
 * $zu(126,1,type)		Something to do with Shared memory objects %ShmObj
 * $zu(126,0,type,offset)	Ditto
 * $zu(128,3,1)		Enable debugging
 * $zu(128,3,0)		Disable debugging
 * $zu(140,11,from,to)	Copy file at o/s level
 * $zu(143,pid,1)        Freeze job
 * $zu(143,pid,0)        Unfreeze job
 * $zu(150,"DebugBreak")  Call DebugBreak function [win32 only]
 * $zu(159, "Domain\Username", "Password")      Impersonate current Cache process as user [win32 only]. Returns win32-error code.
 * $zu(170,3,key,data)	Encrypt data using key as a private key (used for CSP session key)
 * $zu(170,4,key,data)	Decrypt data using key as a private key
 * $zu(172,0)            Returns the superserver port number (1972 or whatever)
 * $zu(161)		Remove all object memory
 * $zu(164)		Remove all active oid
 * $zu(186,p1,p2,p3,p4,p5,p6,p7,p8) Set programmer's prompt
 * $zu(200,n)            Get license data [obsolete]
 * $zu(201,n)            Get license data


 * $bit(arg1,arg2,arg3)	3 argument form of $bit - what does it do?

NB propertyNo cannot be a variable (use *@($zobjval(oRef,"_propertyNo_")") )
 * $zobjnew(class)		Create new instance of class
 * $zobjnext(oRef)		Iterate through instantiated objects in memory of current proces
 * $zobjclassmethod(class,method,argument)	Invoke class method
 * $zobjstate(oRef)	Does object exist
 * $zobjval([oRef],1,0,3,1)	? Concurrency mode
 * $zobjval(oRef,0,,,,2)	Object reference count
 * $zobjval(oRef,0,,,,3)	Object Oid
 * $zobjval(oRef,0,,,,4)	Object reference list
 * $zobjval(oRef,0,,,,5)	isusercount oref
 * $zobjval(oref,propertyNo)	Property of object (^oddDEF(class,"a",property,11)=propertyNo ??)
 * $zobjval([oRef],propertyNo,0,3,propertyNo)	? (oRef defaults to the value of %this if not specified)
 * $zobjval([oRef],propertyNo,0,3,propertyNo)	Property value?
 * $zobjval([oRef],propertyNo,0)	An oref, if property is of type object
 * $zobjmod([oRef],propertyNo)		Property modified flag


 * $listsame(list1,list2)	?
 * $list(x,-1)		Returns value of last element in the list


 * $zf("OPENFD",file)	Open file descriptor
 * $zf("CLOSEFD",fd)	Close file descriptor
 * $zf("TEST",arg1,...)	Test function
 * $zf("CATBYTES",arg)	Prints arg
 * $zf("ERROR",n)		Fires error number n

2 = Windows 3 = Unix
 * $zversion(0)		Returns a bitstring containing version information (Unicode?)
 * $zversion(1)		Type of Operating system 	1 = VMS
 * $zqc(a,b,c)		%ShmObj

Set Command

 * Set $bit(arg1,arg2)	Set a bit
 * Set $zobjval(...)
 * Set $zobjval(...)
 * Set $zobjmod(...)
 * Set $zr=..		Can be set to non-null value (docs say only to null)

Labels

 * label [public|private]	Not just for procedure blocks
 * label(&arg)		Pass by reference indicator (documentation only)
 * label(arg...)		Pass variable number of arguments

Object Syntax

 * lvn.property
 * (oref).property
 * $g(oref).property
 * $s(expr:oref,1:oref).property
 * $$exfunc.property

ssvn

 * ^$|environment|lock(expr)

miscellany

 * w $g(oPatient).%Close and w (oPatient).%Close and d (oPatient).%Close - works ok
 * d $g(oPatient).%Close - gives a syntax error
 * d $zutil(...) - is valid for some $zutil functions
 * d $zf(-1,...) - is valid
 * Attempts to write any file named CACHE.DAT is prohibited.
 * c:\cachesys\bin\csystray.exe  -NOSPLASH	Starts the cube without showing the splash screen
 * d REACT^STU1(cpf,0,2)	Re-activate namespaces

Switches

 * 0    Unused, available for programmer (i.e. customer) use
 * 1    Unused, available for programmer (i.e. customer) use
 * 2    Unused, available for programmer (i.e. customer) use
 * 3    Unused, available for programmer (i.e. customer) use
 * 4    Unused, available for programmer (i.e. customer) use
 * 5    Unused, available for programmer (i.e. customer) use
 * 6    Unused, available for programmer (i.e. customer) use
 * 7    Unused, available for programmer (i.e. customer) use
 * 8    Reserved for InterSystems use - disables DDP, DCP and DTM networking (not ECP)
 * 9    Reserved for InterSystems use - disables DCP logins
 * 10   Suspends all global and routine read/write accesses for all process, except the process that set this switch.
 * 11   Reserved for InterSystems use - Suspends global accesses for all process except the process that set this switch.
 * 12   When this switch is set, new Cache processes are prevented from starting.
 * 13   Marks all databases as read-only (for backup purposes).  Processes that attempt to perform global sets and kills, and routine saves are suspended while this switch is set.  Processes performing read access to globals and routines are not suspended.
 * 14   Suspends all global and routine read/write access for all processes.
 * 15   Reserved for InterSystems use - enables network access from other servers (overrides switches 10,13,14)
 * 16   Reserved for InterSystems use - if set then shadowing will stop (will anything else stop?)
 * 17   Reserved for InterSystems use - disables waiting for journal synchronisation
 * 18   Reserved for InterSystems use - something to do with the length of the queue for disk blocks
 * 19   Suspends transaction processing for all processes, specifically processes are suspended at the TSTART point while this switch is set.
 * 20   Disable dead job cleanup
 * 21   Reserved for InterSystems use
 * 22   Reserved for InterSystems use
 * 23   Reserved for InterSystems use - Prevents the dead job clean-up process from running (this could be switch 20)
 * 24   Reserved for InterSystems use
 * 25   Reserved for InterSystems use
 * 26   Reserved for InterSystems use
 * 27   Reserved for InterSystems use
 * 28   Reserved for InterSystems use
 * 29   Reserved for InterSystems use
 * 30   Reserved for InterSystems use
 * 31   Reserved for InterSystems use

SWSET Utility

 * >DO ^SWSET // to manually set/unset switches
 * >SET %SW=10,%VAL=1 DO INT^SWSET // to programmatically set/unset switches