In Search of...
      the Lost Window

Phil Burk

The windows on the computer screen were designed to simulate the papers on our desk. This metaphor works very well, but is sometimes too close to reality. Documents, letters, notes, and program listings accumulate until I feel like an archaeologist excavating the layers of an ancient civilization whenever I try to find something on my desk. I can date a document by how many inches it is buried below the top surface.

          My Amiga's Workbench can also become cluttered when I have several programs running, each with multiple windows. I became tired of sifting through these windows with the push-back gadgets so I wrote a simple program called FindWindow. With this program, I can now get to any window on the Workbench with one simple action. I thought it would be marginally useful, so ! gave it to a few friends. Much to my surprise, they use it constantly, and it has earned a permanent spot on their Workbench screens. FindWindow opens a very small window that usually sits in the Workbench title bar. When you click on the window with the left mouse button, a popup menu appears with a list of all open Workbench windows. You can select a window which will pop to the front and be activated. Selecting from a popup menu using the left mousebutton may seem strange at first. I chose it because using the right button would require two mouse actions--one with the left button to activate the small window and a second action with the right button to use the menu.

          The program was written using JForth Professional Version 3 available from Delta Research. If you are programming in C or any other fine language, I trust the principles in this program can be applied to your own work.


          Here is a quick Forth lesson to help you read and understand the program listing. Forth has a large dictionary of commands called "words.' Forth words typically operate on a stack of numbers. For example, the plus operator '+' removes 

  the top two numbers from the stack, adds them together, and places the sum on the stack. The print operator '.', pronounced "dot," removes the top number from the stack and prints it. Comments are in parentheses. For example:

             200 123 + .   ( would print 323 )

          This system is called Reverse Polish Notation, or RPN. It is the style used by HP calculators. It may seem a bit odd at first, but is quite easy to learn because everything happens in a simple left to right order.

          To define a new word and add it to the dictionary, Forth uses a colon ' : ', followed by the name of the new word. A "stack diagram" usually follows that describes what is expected on the stack and what is left after execution. A stack diagram that uses curly brackets '{' defines local variables similar to C. The word definition is ended with a semicolon. For example, here is a word called SUMSQ that uses local variables and calculates the sum of the squares of two input values.

     : SUMSQ { a b - a2+b2 , calc sum of squares } 
     a a *   ( calculate square of A ) 
    b b *   ( square B, both squares are on stack )
    ( add together top two numbers on stack--) 
         This could be tested by entering:

     SUMSQ .   which would print  "25".


     Now let's dig into the FindWindow program and see how it works. Here is a pseudo-code description of the program: 

     Read x,y and color parameters from command line.
     Open small window and draw buttons.