}2 ALWITE PROGRAM ROUTINE}8 }6 ~~~~~~~~~~~~~~~~~~~~~~~~ }5 BY }7 GRAHAM STEPHENSON }1 I decided to write this small tutorial after several people asked me how to get the cursor moving with the mouse. You will have selected this article with the mouse already, so you will have already seen this feature in action. }4 Using the right mouse button to select menu options is OK for the vast majority of applications, but what happens when you want to create something simple like a Requester, but you want it to have a look of it's own and not look like the rather boring Amos default? Using the right mouse button for this by selecting the menu is a little unprofessional and it would be much easier if the options were on screen which the user could select with the left mouse button... }1Well, this program is to help you design such a program. The source as it stands will not generate a requester, but with slight modification, it could serve its purpose in many different applications. }4 I hope you find this program useful. All the source code will be in White and the explanation of what it does will be in purple. Incidentally, if you want to see this program up and running, you can load the file called "Witey.Amos" in the source directory into Amos directly. Then you can just chop and change it to your hearts content. }1 If you wish to use it anywhere though, just remember where it came from! A small thanx wouldn't go astray! }1 Dim NAME$(20),HANDLE$(20),GROUP$(20),STATUS(20) }4This will dimension several arrays. Each array will now have 21 dimensions, in other words, be able to hold different values. }1Screen Open 0,640,200,2,Hires }4Open a screen in Hires mode in 2 colors }1Colour 1,$FFF}4 Sets colour 1 to white }1For T=1 To 20 Read NAME$(T),HANDLE$(T),GROUP$(T) }4 Read the information from the data statements into the required arrays. }1Next T Data "Graham Stephenson","Hawk","Zircon" Data "L. Gears","Gears","Zircon" Data "Phil Shotton","Shot","Zircon" Data "","","" Data "Zex","Frank Henneuse","Zircon" Data "Graham Stephenson","Hawk","Zircon" Data "L. Gears","Gears","Zircon" Data "","","" Data "Cosmic","Peter Davidson","Zircon" Data "Zex","Frank Henneuse","Zircon" Data "","","" Data "L. Gears","Gears","Zircon" Data "Shot","Phil Shotton","Zircon" Data "Cosmic","Peter Davidson","Zircon" Data "Zex","Frank Henneuse","Zircon" Data "Graham Stephenson","Hawk","Zircon" Data "","","" Data "Shot","Phil Shotton","Zircon" Data "Cosmic","Peter Davidson","Zircon" Data "Zex","Frank Henneuse","Zircon" }1Reserve Zone 20}4 Reserve enough memory to store the information for up to 20 zones. A common problem I have encountered is that you forget about this command, and you think the problem lies elsewhere within the Zone definition. Don't forget about this command! }1 For T=1 To 20 }4Set the number of loops }1 If Len(NAME$(T))>0}4 Check if the length of the array is greater than one. If it is't, then nothing is meant to be displayed in that window, so a window isn't opened. }1 Wind Open T,0,T*8,76,1 }4 Open a window }1 Print NAME$(T);}4 Print the corresponding title in each window. }1 Set Zone T,0,T*8 To 640,(T+1)*8}4 Since Amos cannot check whether the mouse is within a window (yet?!) you have to set up a zone exactly around the window. }1 End If Next T }1Continue with loop Curs Off }4 Remove the cursor from the display after the last window has been opened. Now to introduce two variables: X - this holds which zone the mouse is currently in. XOLD - holds which zone the mouse was in in the previous loop. }1Do }4 Start the main loop }1 X=Hzone(X Mouse,Y Mouse)}4 Check which zone the mouse is currently in }1 If X=0 Then XOLD=0}4 If the mouse is not in any zones, then set the other variable accordingly. }1 If X>0 and XOLD<>X}4 If the mouse is in a zone, and the zone it is in was different from the one before it, the following is carried out: }1 Window X}4 Direct output to the window X (since the zones are defined exactly around the windows, selecting the same window as the current zone gives the impression that the mouse has actually collided with the window and not the invisible zone) }1 Inverse On }4 Reserve the paper and pen colours for the current window. This gives the impression that the window is highlighted. }1 Clw }4 Clear the window in the current paper colour }1 STATUS(X)=1}4 This variable sets that the window is currently in Inverse mode. More on this later. }1 Print NAME$(X);}4 Output some text to the screen }1 Curs off}4 Remove the cursor from the display }1 XOLD=X}4 The "old zone" is now the new one. }1 End If }1 For N=1 To 20}4 This small loop is to check the Status of each window. If the status of the window is "1" and the mouse is not currently in the zone surrounding that window, the window should now revert back to the standard display. In other words, it should not be highlighted. }1 If STATUS(N)=1 and N<>X}4 Check the status of the current window. Is it inversed? If it is, then check if the current window is different from the current zone. If it is, then it is necessary to set the old window back to not being in inverse mode. This sounds complicated and is difficult to explain, but look through the source code on the disk and mess about with it to get a better understanding. }1 Window N}4 Back to the old window }1 Inverse Off }4 Knock inverse off }1 Clw }4 Clear the window }1 Print NAME$(N);}4 Output some text to the window }1 Curs Off }4 Remove the cursor }1 STATUS(N)=0}4 Set the status of this window to 0, so that is NOT selected (inversed) }1 End If Next N }1 If Mouse Key=1 and X<>0}4 If the mouse key is clicked, and the mouse is in a zone (selecting an option), the following is executed. Please note, that you could be executing absolutely any series of commands here. It is useful if you are wanting a menu for displaying your PD/Utils lists or whatever, since a program can be loaded depending on what you click on. }1 Screen Open 2,640,200,2,Hires}4 Open a separate screen and execute some print commands }1 Cls 0 Print "Information on: ";HANDLE$(X) Print Print "Real Name: ";NAME$(X) Print Print "Group Name: ";GROUP$(X) Print Print "Press a key to continue ... " Curs Off Wait Key Wait for a key press before closing screen 2 ... Screen Close 2 End If Loop }4 Well, that's it! I might do a similar tutorial next month, but tell you how to enhance it even more! End.