CHNOPN
Check whether a channel is in use
WTSupported in traditional Synergy on Windows
|
WNSupported in Synergy .NET on Windows
|
USupported on UNIX
|
VSupported on OpenVMS
|
xcall CHNOPN(channel, status)
Arguments
channel
The expression that contains the channel you want to check. (n)
status
Returned with one of the following values: (n)
1 = The channel is in use.
0 = The channel is closed.
Discussion
The CHNOPN subroutine checks whether a channel is in use by an open file. CHNOPN is functionally identical to DBL$CHOPEN.
Examples
The following program opens a specified file on the first available channel.
.define TTCHN ,1 record filename ,a20 ;Filename to open chn ,d4 ;Channel to open proc open(TTCHN, o, "tt:") xcall flags(4020) do forever begin display(TTCHN, "Enter a filename to open: ") reads(TTCHN, filename) xcall openit(filename, chn) if (chn) writes(TTCHN, "Opened " + filename + "on channel #" + %a(chn)) end ;End of do forever loop end ;End of main routine subroutine openit ;Find an available channel a_file ,a ;Contains name of file to open a_rchn ,d ;Returned with next available channel record stat ,d1 ;Used with XCALL CHNOPN proc for a_rchn from 2 thru 1024 begin xcall chnopn(a_rchn, stat) if (.not.stat) begin open(a_rchn, i, a_file) [err=nofile] xreturn end end operr, writes(TTCHN, "Exceeds maximum channels " + a_file) goto oprtn nofile, writes(TTCHN, "Cannot open " + a_file) oprtn, clear a_rchn xreturn endsubroutine