system

Top  Previous  Next

system

o=new("system")

 

The system object provides access to operating system information and services.  Note that the system object is a static object, meaning there is only one object instantiated for any and all new() functions executed.

 

Properties

All properties are read-only.

 

home$ is the path of the UnForm server's home directory.

networkid$ is the server's hostname or IP address.

osname$ is the specific operating system name, such as "MS-WINDOWS", or " UNIX-Linux-RedHat".

ostype$ is "win" on Windows, and "*nix" on Unix or Linux-like systems.

user$ is the user account running the UnForm server.

 

Methods

copyfile(from$,to$[,errmsg$]) copies the from$ file to the to$ file.  If an error occurs, such as a permission violation or if the to$ file already exists, errmsg$ is filled with a message.  The function returns true (1) on success, false (0) otherwise.

deletefile(filename$[,errmsg$]) erases the specified file.  It returns true (1) if successful, or false (0) and fills errmsg$ if not.

getcmd$(cmd$[,output$]) executes the specified command, captures its standard output, and returns the contents of the standard output.  If output$ is provided, it must be a file name that will also contain the standard output result.

newfile$(filename$[,pad]) creates a new file, with a sequencer before the file extension to ensure uniqueness.  Directory paths are created if needed, then the file name is created if it does not exist.  If it does exist, a sequencer is added until a unique name is created.  If the pad option is supplied, the sequencer is a 0-filled value of pad digits.  In the case of a pad value, the sequencer is always used.  If pad is 0 or not supplied, and the initial file does not exist, the initial file without a sequencer is created.  When used, the sequencer value starts with 1, and is always prefixed with a dash (i.e. /tmp/a/b-1.txt" or "/tmp/a/b-0001.txt").  If sequences exceed the capacity of the pad size, the pad size will be exceeded with extra digits as necessary.

 

The method returns the filename created.

renamefile(from$,to$[,errmsg$]) renames the from$ file to the name specified in to$.  It returns true (1) if successful, or false (0) and fills errmsg$ if not.

runcmd(cmd$) executes the specified command and returns its exit code.

tempfile$([extension$][,retain]) creates a temporary work file that is erased at the end of the current job.  The file name is returned.  If extension$ is provided, the file will have that extension.  Otherwise, a .tmp extension is used.  The file must be opened to work with it.  This function can be used to generate an empty file to use with other operating system commands.  Normally work files are marked for deletion at the end of a job, but if the retain option is supplied and true (<>0) the file is not so marked.

tempfile([extension$][,retain]) creates and opens a temporary work file that is erased at the end of the current job.  The channel number of the opened file is returned.  If extension$ is provided, the file will have that extension.  Otherwise, a .tmp extension is used.  Use PTH(chan) to obtain the file name. Normally work files are marked for deletion at the end of a job, but if the retain option is supplied and true (<>0) the file is not so marked.

winprtprinters$() returns a linefeed ($0A$) delimited list of printer names available for *winprt* or *windev* printing on a Windows UnForm installation.

winprttrays$(printer$) returns a list of tray numbers and descriptions for the specified Windows printer.  Windows print driver vendors often use user-defined tray numbers above 256, rather than tray numbers that match traditional PCL values.  The list contains linefeed ($0A$) delimited tray lines, where each tray line contains a tab ($09$) delimited tray number and description.