WINDOWX by Paul Dias from Your Sinclair, May & June 1991 Even the most anoraked of die-hard Spec-chums must have looked at the windows and pull-down menus on the ST and Amiga at one time or another and thought, "Hmm, they're a bit good - perhaps I ought to get one of those." But now there's no need! Thanks to Paul Dias, pretending you've got a really expensive computer is simply a matter of typing in his WindowX program, withdrawing about #300 cash from the bank and setting fire to it. The first thing to do is take a look at the listing. Not a pretty sight, eh? But at least there's no hex to worry about - just lots of DATA statements. (Groan.) Come on - stiff upper lip. Get it all typed in and save it onto a tape. Then run the program and, if no errors are reported, save the machine code it generates onto a tape by doing SAVE "WINDOWX" CODE 62000,880. Right. The next thing to do is decide what to do with it. The thing is, you see, I'll be printing a short demo program in next month's Pitstop which will show just what the program is capable of. But, in case your patience just can't handle that sort of treatment, I'm giving you all the info you'll need to get a few windows and menus of your own up and running this month. I'd strongly advise you to hang on till the next issue before trying anything too serious, but the choice is of course yours. The first step, once you've saved the code onto tape, is to CLEAR 41209 to give you some space in memory and then LOAD "" CODE to load the code back in. You'll then need to include the following lines at the start of your program: DEF FN d(p,q,c)=USR 62000 DEF FN w(y,x,d,w,c,t,b)=USR 62003 DEF FN s(s,m)=USR 62006 DEF FN r(m,s)=USR 62009 You'll now be able to use the four main functions of WindowX, which are as follows: Drawing the Desktop Proper computers have some sort of background on which to draw all the windows and things. If you go LET a=FN d(p,q,c) you'll be provided with just such a facility. The screen will be filled with lines of two alternating bytes, 'p' and 'q', which work a bit like UDGs. 'c' is the attribute value (ie. colour). So, to create a yellow and black chequerboard pattern, use the command LET a=FN d(170,85,48). Drawing Windows This is where things really hot up. To draw a window (or, indeed, a menu) at the location of your choice do LET a=FN w(y,x,d,w,c,t,b). 'y' and 'x' are the character row and column positions for the window, 'd' and 'w' are the depth and width of the window and 'c' is the attribute value of the window. You can also specify a 'title bar' across the top of the window and a 'close box' in the corner by setting 't' to 0 for nothing, 1 for a title bar and 2 for a title bar and a close box. If you want a border round the window to give a shadow effect, set 'b' to 1, otherwise set to 0. Note that the windows are purely cosmetic - you can't 'redirect' text into them or anything elaborate like that. (Just what do you expect in 880 bytes?) Storing and Recalling the Screen Having finished with a menu or a window it's nice to be able to get rid of it and restore the screen to the way it was before. To do this you'll need to save the screen (or part of it) in memory and then bring it back again, which is where these two functions come in. You can store a third of the screen at a time, and up to nine thirds can be held in memory at once (that's three whole screens). To store a third of a screen do LET a=FN s(s,m) where 's' is the number of the third you want to store (1-3 where 1 is the top third) and 'm' is the location in memory where you want it stored (1-9). [To restore a third of the screen do] LET a=FN r(m,s) where 'm' and 's' are as above, only the other way round. You don't have to replace the third in the place you got it from, which may well be handy. And if you're not planning on using all nine storage locations you won't have to CLEAR quite such a low number before loading the program. For example, if you don't want any space reserved at all CLEAR 61999. Each third needs 2310 bytes, so if you want three of them CLEAR 55069. I can tell you're impressed. Just wait till you see the demo program. ... Here, as promised, is the demo to go with the WindowX program featured in last month's Pitstop. A thorough perusal should reveal plenty of hot tips on how to create the smartest windows around. For example, a UDG is defined in line 110 to add a touch of class to the menus. That sort of thing. Being a mere demo the program doesn't really do a great deal, but it looks dead impressive all the same. You will, of course, need to have run last month's program before you attempt to use this one.