%SYN_FREECHN

Get the next available channel

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
channel = %SYN_FREECHN([start][, end])

Return value

channel

The number of the next available channel, or 0 if no channel is available. (n)

Arguments

start

(optional) The first channel to consider. (n)

end

(optional) The last channel to consider. (n)

Discussion

%SYN_FREECHN checks the channels between start and end, if specified, and returns the first available channel.

In Synergy .NET, when using multi‑threading, don’t use %SYN_FREECHN. Instead, pass a variable to your OPEN statement that is 0. The runtime will generate a channel number automatically. For example,

open(var=0, i, "mylst")

See OPEN for more information.

Examples

The example below checks the channels between 101 and 199 and returns the first available channel encountered.

record
    chn         ,i4
proc
    chn = %syn_freechn(101, 199)
    if (.not. chn)
      writes(1, "no channels available")