| **Navigation:**  [[introduction.htm|Language Reference]] > 13 - Built-in Functions >====== STATUS (return file or window/report status) ====== | [[start return new execution thread .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[stop suspend program execution .htm|{{btn_next_n.gif|Next page}}]] | | || | | **STATUS** | **(**| //file// |**)** | | | | | //window //__|__ | {{blk2blue.jpg|blk2blue.jpg}} | **STATUS** | Returns the passed file, window or report status. | | //file// | The label of a FILE statement. | | //window// | The label of a WINDOW, APPLICATION, or REPORT structure, or valid built-in variables TARGET, PRINTER, or SYSTEM. | The **STATUS** procedure returns zero (0) if the //file// is not open, and the //file's access mode// if it is open. If the //access mode// is actually zero (Read Only / Any Access), 40h (Read Only / Deny None) is returned (see OPEN). If the //file// is threaded, STATUS is for the current thread only. **STATUS** can also be used to check the state of a WINDOW or REPORT structure. If the passed WINDOW or REPORT exists and is opened, **STATUS** returns zero (0). If the passed WINDOW or REPORT exists but either has not been opened or has been closed, **STATUS** returns one (1). If the passed parameter is not a valid WINDOW or REPORT structure, **STATUS** returns two (2). To simplify testing of results returned from calls to **STATUS**(WINDOW), the following declarations have been added to EQUATES.CLW: **WINDOW:OK EQUATE(0)** **WINDOW:NotOpened EQUATE(1)** **WINDOW:BadWindow EQUATE(2)** Built-in variables TARGET, PRINTER and SYSTEM can be passed as parameters to calls to STATUS(WINDOW). The function always returns WINDOW:OK if the actual parameter is PRINTER or SYSTEM. **Return Data Type:     **LONG **Example:** ** IF ****STATUS****(DataFile) % 16 = 0        !Opened Read-Only?** **   RETURN                            !get out** ** ELSE                                !Otherwise** **   EXECUTE DiskAction                !Write record to disk** **     ADD(DataFile)** **     PUT(DataFile)** **     DELETE(DataFile)** **   END** ** END** ** CASE ****STATUS(PassedLabel)****            !Check parameter passed** **  OF WINDOW:OK                       !if window is good, and opened** **   CYCLE                             !continue** **  OF WINDOW:NotOpened                !if window is good, but not opened** **   OPEN(PassedLabel)                 !open it** **  OF WINDOW:BadWindow                !bad window?** **   MESSAGE('Invalid Window','Note:') !exit procedure** **   RETURN** ** END** **See Also:** [[open open a data structure .htm|OPEN]] [[exists return file existence .htm|EXISTS]]