Drawsave

By Will Watts

Originally published in EUG #05

The September 1986 edition of Electron User contained a rather ingenious graphics program called DRAW WRITER which enabled the user to create a drawing, design or diagram, then save the BASIC commands such as MOVE, DRAW, PLOT, etc as a SPOOLed text file. As well as drawing solide and dotted lines in colour, it could also create triangles, polygons and circles, both filled and unfilled. As you can imagine, the listing was very long and I never got round to typing it in. Eventually I decided I really needed a program like DRAW WRITER and set about writing my own cut-down version. This took a bit of thought but after several set-backs I came up with DRAWSAVE. I was quite proud of this little effort as I worked the whole thing out myself and didn't copy anything from the EU original. (Perhaps this shows!!)

DRAWSAVE is really only a line-drawing program, but there is no reason why other routines should not be added later, and in the meantime it's still a useful utility.

When the program is RUN you will see a white Mode 4 screen and nothing else! Only when you use the 'Movement keys' (Please see the key table) will a small black dot appear which can be moved around the screen. Once the dot is at the point where you want your drawing to start, press the S key to store the graphics co-ordinates of that point. These will appear at the bottom left of the screen, along with another number which tells you how many points have been stored so far.

You can now "rubberband" around the screen, pressing S each time a point needs to be stored and the line 'fixed' on screen. To leave rubberband mode in order to move the dot/cursor to another part of the screen press M to enter into 'Movement' mode. Once the dot is in its new position, press S to store the point and resume rubberbanding.

The program is set to store a maximum of 150 points. This is governed by the three arrays which are dimensioned in line 30. I chose 150 because I use a memory-munching ADFS disk system, but E00 disk or tape users could probably increase the array dimensions somewhat.

When you are satisfied with your design or have stored the maximum number of points allowed, press P. The screen will clear and you will be asked for a procedure name to call the present list of commands. The name must be a continuous string with no spaces but the 'underline' character may be used to break up multi-word names.

You will then be asked for a file name. This must be no longer than 10 characters, again with no spaces. The list of drawing commands will then appear on screen and be automatically saved to tape or disk. Make sure you have a disk already mounted in the drive or a blank tape in the recorder!! Once the SPOOLed file has been saved (you will receive an on-screen message!), you will be asked if you want to return to a blank screen or have the last batch of stored points re-drawn.

Using this simple method you could have a drawing with up to 150 points already on screen (and saved to tape/disk) which you could then add another 150 points to. This second batch of points could then also be saved - using a different filename.

These two SPOOLed files can now be joined together in the following manner:

  1. Clear the Electron's memory with CTRL and BREAK.
  2. Type NEW, followed by RETURN (just to be on the safe side).
  3. Load the first file you saved by typing "*EXEC filename" (RETURN)
  4. After the file appears, type "RENUMBER 1,1" (RETURN)
  5. Now type "*EXEC second filename" (RETURN)
  6. Once the second file has loaded, type "RENUMBER" once more then press RETURN.
You should now have a program which consists of two procedure definitions. If these procedures are both parts of the same drawing (and they might not be in some cases!), you can delete the second procedures definition line and the ENDPROC statement leaving one long procedure with the FIRST procedure's name!

It is then just a matter of adding a few lines to the start of the program thus:

      >1 MODE 
      >2 PROCprocedure-name
      >3 END
Save the program as normal then RUN it. Your design should appear on screen.

DRAWSAVE can also be used to create multi-coloured line drawings or 'layered' diagrams and even to produce simple animation! More about this next time.

Key Functions
Z - Left, X - Right, * - Up, / - Down
M - Move, P - Print To Screen & SPOOL, S - Store Point Coordinates
B - Return To Blank Screen, R - Redraw Last Points

Will Watts, EUG #5