This post introduces a function to check the status of a window handle: WStat(). It is also part of my Action! library window file LIBWIN.ACT.
Status (WStat)
The status routine simply returns the window handles status. It will be either WSFREE (not in use), or WSUSED (used). It requires one parameter which is the window handle number to check.
The function works in the following manner:
- It computes the window handles memory location.
- It then returns the window handles status byte value.
; -------------------------------------- ; Func..: BYTE WStat(BYTE n) ; Desc..: Tests if window handle is open ; Params: n = number of window handle ; Return: WSUSED (in use) or ; WSFREE (not used) ; -------------------------------------- BYTE FUNC WStat(BYTE bN) ; Find window handle record pWn=baW+(WRECSZ*bN) RETURN(pWn.bS)
Usage
The demonstration program has once again been expanded. This time a fourth window is opened. It it, the status of the first 5 windows is displayed. Notable differences are in the section commented for window 4:
; Program: WINDOW.ACT ; Author.: Wade Ripkowski ; Date...: 2016.04 ; Desc...: Test Windowing Library ; License: Creative Commons ; Attribution-NonCommercial- ; NoDerivatives ; 4.0 International ; Include library INCLUDE "D3:DEFINES.ACT" INCLUDE "D3:DEFWIN.ACT" INCLUDE "D3:LIBSTR.ACT" INCLUDE "D3:LIBWIN.ACT" INCLUDE "D3:LIBMISC.ACT" ; Start MODULE PROC Main() ; Window handles BYTE bW1,bW2,bW3,bW4,bLp,bS ; Init Window System WInit() ; Open window 1 bW1=WOpen(10,5,20,7,WINVOFF) WTitle(bW1,"One") WPrint(bW1,1,1,"Row 1 Column 1") WPrint(bW1,1,5,"Unfinished Bitness") ; Open window 2 bW2=WOpen(5,15,30,6,WINVON) WTitle(bW2,"TWO") WPrint(bW2,2,2,"2,2") WPrint(bW2,WPCENT,4,"Inverse ATASCII Podcast") ; Open window 3 bW3=WOpen(15,8,10,10,WINVOFF) WTitle(bW3,"Three") WPrint(bW3,1,3,"Hello") WPrint(bW3,3,5,"Hello") WPrint(bW3,1,7,"Hello") ; Wait for a keystroke or console key WaitKC() ; Clear window 3 WClr(bW3) ; Draw \ in window 3 WPos(bW3,1,1) WPut(bW3,42) WPos(bW3,2,2) WPut(bW3,42) WPos(bW3,3,3) WPut(bW3,42) WPos(bW3,4,4) WPut(bW3,42) WPos(bW3,5,5) WPut(bW3,42) ; Open window 4 bW4=WOpen(3,3,15,9,WINVOFF) WTitle(bW4,"4-Status") WPrint(bW4,1,1,"Window Status") WPrint(bW4,1,2,"------ ------") ; Loop through the first 5 window handles for bLp=0 to 4 DO ; Get the status bS=WStat(bLp) ; Print the window handle # WPos(bW4,6,3+bLp) WPut(bW4,bLp+48) ; Print the handle status if bS=WSUSED then WPrint(bW4,8,3+bLp,"Used") else WPrint(bW4,8,3+bLp,"Free") fi OD ; Wait for a keystroke or console key WaitKC() ; Close window 4 WClose(bW4) ; Close window 3 WClose(bW3) ; Close window 2 WClose(bW2) ; Close window 1 WClose(bW1) RETURN
Results
When the program is run it produces the following results. All but the last screen shot are omitted as they have been covered before. The important output (for this post) is what appears in window 4:
That concludes the Action! window library routines. The next post will feature the first gadget, a progress indicator.