%TNMBR
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
The %TNMBR routine is deprecated; we recommend that you use %JBNO instead for a unique job or process ID, rather than relying on static terminal numbers. |
terminal = %TNMBR([service_flag])
or
xcall TNMBR(terminal[, service_flag])
Return value
terminal
The number of the terminal that’s running the current program. (i)
Arguments
service_flag
(optional) One of the following flags (Windows only): (n)
0 = The program is running with dbr.exe. (default)
1 = The program is running with dbr.exe and as a service, or as a scheduled task and the user is not logged in.
2 = The program is running with dbs.exe, dbssvc.exe, or dbspriv.exe.
Discussion
TNMBR returns the terminal number that corresponds to the program’s TT: device. A terminal number can be up to eight digits long. Synergy DBL’s interpretation of the terminal number depends on the operating system on which your program is running.
On all operating systems, the TNMBR routine first looks at the TNMBR environment variable and uses its value if it is set. (The disadvantage of this method is that more than one terminal can easily be assigned the same terminal number. For example, if two people define TNMBR as equal to 1 in their log-in file and both are logged in at the same time, both of their terminals will have the number 1.)
If the TNMBR environment variable is not set, Synergy DBL determines the terminal number as follows:
How Terminal Numbers Are Determined |
|||
---|---|---|---|
Platform |
Terminal number assignment |
||
Windows |
0 = The process is a logged-in user session. -1 = The job is running as a service, as a scheduled task when the user is not logged in, or using dbs.exe, dbssvc.exe, or dbr.exe -n. |
||
Unix |
From the file /etc/ttys, if the terminal name has the form /dev/dev_type/unit_number, TNMBR searches the /etc/ttys file for dev_type/unit_number. OR Based on the name of the terminal: 0 = The process is a console application. -1 = The job is running detached, regardless of the terminal device specification. positive = All other instances. Synergy DBL calculates a number from the device name that is unique if it was found in /etc/ttys. The device name may vary, depending on the flavor of the operating system and the type of terminal controller used. The terminal number is not necessarily compatible with other platforms or with DIBOL terminal numbers. We recommend that you not make assumptions as to the correspondence between terminal numbers and terminal names, other than the uniqueness of a terminal number for a local system. For example, using the number based on the name of the terminal, /dev/tty12 results in 13, /dev/tty0 results in 1, and both /dev/tty1a and /dev/tty1b result in 2. The “number based on filename” method is the default method if the /etc/ttys file is not present and the TNMBR environment variable is not set. If you desire a unique value, use the /etc/ttys file.
|
||
OpenVMS |
0 = OPA0: -1 = The job is running detached, regardless of the terminal device specification. -2 = The process is a network process. -3 = The process is a batch process. positive = All other instances Synergy DBL calculates a unique number from the device name. The device type (for example, TT) may vary, depending on the type of terminal controller used. The terminal number is not necessarily compatible with other platforms or with DIBOL terminal numbers, and it may vary from release to release. We recommend that you not make assumptions as to the correspondence between terminal numbers and terminal names, other than the uniqueness of a terminal number for a local system. If you set system option #17, %TNMBR uses the physical device to determine the terminal number for a virtual terminal. If you don’t set option #17, %TNMBR returns a number based on the VT device specification for a virtual terminal.
|
See also
- TNMBR environment variable
- Using dbr or dbs as a scheduled task (Windows)
Examples
The following example creates a unique filename.
subroutine bld_tmp .define TMPCHN ,2 record term ,d3 tmpnam ,a11,"tmpfile.XXX" ext ,a3 @tmpnam + 7 proc xcall tnmbr(term) ext = term,’XXX’ open(TMPCHN, o, tmpnam) xreturn endsubroutine