Examples of OPEN Statements

The following example opens file FILEID. Execution of the program is suspended until FILEID is open.

OPEN(FILEID)

The following example opens subfile I of port file FILEID and offers it for matching. Control is returned to the program when it is determined whether the host can be reached.

OPEN(FILEID[SUBFILE I],OFFER)

The following example opens subfile I of port file FILEID and a dialog request is sent. The program is suspended until dialog establishment is complete.

OPEN(FILEID[SUBFILE I],WAIT)

The following example opens subfile I of port file FILEID. The AVAILABLE control option is a nonpreferred way of verifying OPEN WAIT with AVAILABLEONLY = TRUE. When AVAILABLEONLY = TRUE, the OPEN attempt fails if the correspondent endpoint cannot be reached immediately. If dialog can currently be established, the subfile is opened, the result returned by the OPEN statement is 1, and PROCESSOPEN is called; otherwise, an error result is returned and PROCESSOPEN is not called.

IF OPEN(FILEID[SUBFILE I],AVAILABLE) = 1 THEN PROCESSOPEN

The following example opens subfile 1 of port file FILEID. The program is suspended until a dialog is established or until T minutes have elapsed.

OPEN (FILEID [SUBFILE 1], WAIT, CONNECTTIMELIMIT = T)

The following example opens subfile 1 of port file FILEID. When the dialog request is sent, the information "MYDATA" is sent to the correspondent process as associated data.

OPEN (FILEID [SUBFILE 1], ASSOCIATEDDATA = "MYDATA")

The following example opens subfile I of port file FILEID. Control returns to the program as soon as the open process has begun, because the DONTWAIT option is included. When a matching subfile is found, 14 characters of information are taken, beginning at the location pointed to by PTR; the 14 characters are sent to the correspondent process as associated data.

OPEN (FILEID [SUBFILE I], DONTWAIT, ASSOCIATEDDATALENGTH = 14,
      ASSOCIATEDDATA = PTR)