On my system, the first window title printed was:
Amiga_DOS_Shell

Each window contains a pointer to the next window. The last window contains a zero. Thus, we can scan this list in a loop until we get a zero window pointer. Let's get the next window. Enter:

mywind s@ wd_NextWindow -> mywind mywind (This is on the above line !!!)

\ Is it zero?
mywind s@ wd_title
0count type

Since the Amiga is a multi-tasking system, it is possible for windows to be opening and closing while we scan the list of windows. When scanning any system lists you should first call Forbid() and Permit(). We did not do this in our interactive example because it is impolite to Forbid() other tasks for too long a time.

To see how FindWindow uses the above technique to get the window names, see the following words in the listings:

GET.ACTIVE.SCREEN in popup_Menus.f
FW.DRAW.NAMES in Find_Window.f

FindWindow filters out windows with blank titles, BACKDROP windows, and its own windows.

POPUP MENUS

I wanted the user to be able to place the program's main window anywhere on the screen and have the menu pop up right over that window. I also wanted to use the left mouse button. Thus, I could not use Intuition Menus. I decided to implement a pop.up menu toolbox as a stand-alone toolbox so that it could be used with other programs as well.
To make a menu pop up, you would call POPUP.OPEN with the x,y-position, width, number of items, and an optional title. This just opens a BORDERLESS window. If the window extends beyond the edges of the screen, it will be moved to fit. This is determined by looking at the screen width and height in (POPUP.OPEN).
You can then draw the text for the menu items by calling POPUP.DRAW.TEXT with a text string and an item. It is assumed at this point that the mouse button is still down, because a mouse down triggered the menu to pop up. We now call POPUP.SCAN which tracks the mouse, highlighting items as needed until the mouse button is released. POPUP.SCAN returns the item number chosen. To remove the popup menu, call POPUP.CLOSE.

COMPILING FindW!ndow

You can type in the source code for FindWindow or download it from GENIE in the Amiga section. It is item number 14135.
JForth has the ability to create a small stand-alone application from a compiled application. To compile FindWindow and to create a stand-alone application, enter in the CLI:

RUN COM:JForth INCLUDE make_fw

To test the program, enter in JForth or the CLI:

FindWindow -X 260 -F 3

You can modify and test the program directly from JForth without cloning it. To make this a permanent part of your Workbench, copy FindWindow to your C: directory; then RUN it from your startup sequence.

I hope this program will be useful to you. If you have comments or questions, or would like to get the FindWindow program and source on a floppy disk, please feel free to contact me.

All source code and executable files for In Search of the Lost Window can be found on the

ACs TECH Disk Vol 2 Number 4