%TNMBR

Return the terminal number

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
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

Important

We consider TNMBR to be a deprecated feature, in part due to the popularity of Telnet. We recommend that you use %JBNO instead for a unique job or process ID, rather than relying on static terminal numbers.

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. 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. No assumptions should be made 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 a unique value is desired, the /etc/ttys file should be used. See Terminal numbers used by Synergy DBL in the “UNIX Development” chapter of the Professional Series Portability Guide for more information on /etc/ttys.

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. No assumptions should be made as to the correspondence between terminal numbers and terminal names, other than the uniqueness of a terminal number for a local system.

See also

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