Home » Archimedes archive » Acorn Computing » 1993 06 Mega Disk.adf » 93_06 » HelixBasic/Examples/Circle

HelixBasic/Examples/Circle

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn Computing » 1993 06 Mega Disk.adf » 93_06
Filename: HelixBasic/Examples/Circle
Read OK:
File size: 0918 bytes
Load address: 0000
Exec address: 0000
File contents
Example 1
---------

This program is going to open a window and when the mouse is clicked on the icon bar, a circle of lines will be displayed within the window.

Step 1)

Create a new program and then a new window (either from the menus or by double clicking on the window title).

Step 2)

Within the window editor give the window a title but leave the name as Untitled1. This is the name by which the window will be referenced as throughout the program. Close the window and it will appear in the program window.

Step 3)

Create a procedure and give it a new name, circle. Next build the program up :-

FOR r=0 TO PI STEP PI/60
 x=SIN(r)*500
 y=COS(r)*500
 LINE Untitled1,black%,500-x,500-y,500+x,500+y
NEXT

The first part is a standard setup for a FOR ... NEXT loop and builds the co-ordinates for a circle within the window.

The LINE command takes a window to place the line within and then a colour. The colour is specified in 24 bit format but there are already 128 variables with pre-programmed variables of which black% is one. The next parameters state the start and end positions of the line.

Step 4)

Double click on the icon-bar info to get the statistics about the program. Fill in this form as shown :-

  Program Name : !Circle
       Purpose : Draw a circle in a window
        Author : My Name
       Version : 1.00

Select Command : OPENWINDOW Untitled1
  Menu Command : END
Adjust Command : PROCcircle

This will now cause the window to open upon a select command and the information to be displayed on the adjust command. The program will terminate when the menu button is selected.

The program can now be saved out as !Circle and run.

Step 5)

Now create a new menu and add two new entries to this. Change the information as shown

First
-----

Entry Name : Info
Select the Info Box radio icon.

Second

Entry Name : Colour
Select the Colours radio icon
Entry Information : black%

Third

Entry Name : Quit
Selection Command : END

Step 6)

Double click on the Untitled1 window and enter in the Menu command section :-

OPENMENU Untitled1,MOUSEPOSX-64,MOUSEPOSY+32

Again the program can be saved and run


Things to try
-------------

Other menu items can be added for printing the window, or saving it out as a draw file.
For this purpose use either the PRINTWINDOW command or the SAVEDRAW command.
00000000  45 78 61 6d 70 6c 65 20  31 0a 2d 2d 2d 2d 2d 2d  |Example 1.------|
00000010  2d 2d 2d 0a 0a 54 68 69  73 20 70 72 6f 67 72 61  |---..This progra|
00000020  6d 20 69 73 20 67 6f 69  6e 67 20 74 6f 20 6f 70  |m is going to op|
00000030  65 6e 20 61 20 77 69 6e  64 6f 77 20 61 6e 64 20  |en a window and |
00000040  77 68 65 6e 20 74 68 65  20 6d 6f 75 73 65 20 69  |when the mouse i|
00000050  73 20 63 6c 69 63 6b 65  64 20 6f 6e 20 74 68 65  |s clicked on the|
00000060  20 69 63 6f 6e 20 62 61  72 2c 20 61 20 63 69 72  | icon bar, a cir|
00000070  63 6c 65 20 6f 66 20 6c  69 6e 65 73 20 77 69 6c  |cle of lines wil|
00000080  6c 20 62 65 20 64 69 73  70 6c 61 79 65 64 20 77  |l be displayed w|
00000090  69 74 68 69 6e 20 74 68  65 20 77 69 6e 64 6f 77  |ithin the window|
000000a0  2e 0a 0a 53 74 65 70 20  31 29 0a 0a 43 72 65 61  |...Step 1)..Crea|
000000b0  74 65 20 61 20 6e 65 77  20 70 72 6f 67 72 61 6d  |te a new program|
000000c0  20 61 6e 64 20 74 68 65  6e 20 61 20 6e 65 77 20  | and then a new |
000000d0  77 69 6e 64 6f 77 20 28  65 69 74 68 65 72 20 66  |window (either f|
000000e0  72 6f 6d 20 74 68 65 20  6d 65 6e 75 73 20 6f 72  |rom the menus or|
000000f0  20 62 79 20 64 6f 75 62  6c 65 20 63 6c 69 63 6b  | by double click|
00000100  69 6e 67 20 6f 6e 20 74  68 65 20 77 69 6e 64 6f  |ing on the windo|
00000110  77 20 74 69 74 6c 65 29  2e 0a 0a 53 74 65 70 20  |w title)...Step |
00000120  32 29 0a 0a 57 69 74 68  69 6e 20 74 68 65 20 77  |2)..Within the w|
00000130  69 6e 64 6f 77 20 65 64  69 74 6f 72 20 67 69 76  |indow editor giv|
00000140  65 20 74 68 65 20 77 69  6e 64 6f 77 20 61 20 74  |e the window a t|
00000150  69 74 6c 65 20 62 75 74  20 6c 65 61 76 65 20 74  |itle but leave t|
00000160  68 65 20 6e 61 6d 65 20  61 73 20 55 6e 74 69 74  |he name as Untit|
00000170  6c 65 64 31 2e 20 54 68  69 73 20 69 73 20 74 68  |led1. This is th|
00000180  65 20 6e 61 6d 65 20 62  79 20 77 68 69 63 68 20  |e name by which |
00000190  74 68 65 20 77 69 6e 64  6f 77 20 77 69 6c 6c 20  |the window will |
000001a0  62 65 20 72 65 66 65 72  65 6e 63 65 64 20 61 73  |be referenced as|
000001b0  20 74 68 72 6f 75 67 68  6f 75 74 20 74 68 65 20  | throughout the |
000001c0  70 72 6f 67 72 61 6d 2e  20 43 6c 6f 73 65 20 74  |program. Close t|
000001d0  68 65 20 77 69 6e 64 6f  77 20 61 6e 64 20 69 74  |he window and it|
000001e0  20 77 69 6c 6c 20 61 70  70 65 61 72 20 69 6e 20  | will appear in |
000001f0  74 68 65 20 70 72 6f 67  72 61 6d 20 77 69 6e 64  |the program wind|
00000200  6f 77 2e 0a 0a 53 74 65  70 20 33 29 0a 0a 43 72  |ow...Step 3)..Cr|
00000210  65 61 74 65 20 61 20 70  72 6f 63 65 64 75 72 65  |eate a procedure|
00000220  20 61 6e 64 20 67 69 76  65 20 69 74 20 61 20 6e  | and give it a n|
00000230  65 77 20 6e 61 6d 65 2c  20 63 69 72 63 6c 65 2e  |ew name, circle.|
00000240  20 4e 65 78 74 20 62 75  69 6c 64 20 74 68 65 20  | Next build the |
00000250  70 72 6f 67 72 61 6d 20  75 70 20 3a 2d 0a 0a 46  |program up :-..F|
00000260  4f 52 20 72 3d 30 20 54  4f 20 50 49 20 53 54 45  |OR r=0 TO PI STE|
00000270  50 20 50 49 2f 36 30 0a  20 78 3d 53 49 4e 28 72  |P PI/60. x=SIN(r|
00000280  29 2a 35 30 30 0a 20 79  3d 43 4f 53 28 72 29 2a  |)*500. y=COS(r)*|
00000290  35 30 30 0a 20 4c 49 4e  45 20 55 6e 74 69 74 6c  |500. LINE Untitl|
000002a0  65 64 31 2c 62 6c 61 63  6b 25 2c 35 30 30 2d 78  |ed1,black%,500-x|
000002b0  2c 35 30 30 2d 79 2c 35  30 30 2b 78 2c 35 30 30  |,500-y,500+x,500|
000002c0  2b 79 0a 4e 45 58 54 0a  0a 54 68 65 20 66 69 72  |+y.NEXT..The fir|
000002d0  73 74 20 70 61 72 74 20  69 73 20 61 20 73 74 61  |st part is a sta|
000002e0  6e 64 61 72 64 20 73 65  74 75 70 20 66 6f 72 20  |ndard setup for |
000002f0  61 20 46 4f 52 20 2e 2e  2e 20 4e 45 58 54 20 6c  |a FOR ... NEXT l|
00000300  6f 6f 70 20 61 6e 64 20  62 75 69 6c 64 73 20 74  |oop and builds t|
00000310  68 65 20 63 6f 2d 6f 72  64 69 6e 61 74 65 73 20  |he co-ordinates |
00000320  66 6f 72 20 61 20 63 69  72 63 6c 65 20 77 69 74  |for a circle wit|
00000330  68 69 6e 20 74 68 65 20  77 69 6e 64 6f 77 2e 0a  |hin the window..|
00000340  0a 54 68 65 20 4c 49 4e  45 20 63 6f 6d 6d 61 6e  |.The LINE comman|
00000350  64 20 74 61 6b 65 73 20  61 20 77 69 6e 64 6f 77  |d takes a window|
00000360  20 74 6f 20 70 6c 61 63  65 20 74 68 65 20 6c 69  | to place the li|
00000370  6e 65 20 77 69 74 68 69  6e 20 61 6e 64 20 74 68  |ne within and th|
00000380  65 6e 20 61 20 63 6f 6c  6f 75 72 2e 20 54 68 65  |en a colour. The|
00000390  20 63 6f 6c 6f 75 72 20  69 73 20 73 70 65 63 69  | colour is speci|
000003a0  66 69 65 64 20 69 6e 20  32 34 20 62 69 74 20 66  |fied in 24 bit f|
000003b0  6f 72 6d 61 74 20 62 75  74 20 74 68 65 72 65 20  |ormat but there |
000003c0  61 72 65 20 61 6c 72 65  61 64 79 20 31 32 38 20  |are already 128 |
000003d0  76 61 72 69 61 62 6c 65  73 20 77 69 74 68 20 70  |variables with p|
000003e0  72 65 2d 70 72 6f 67 72  61 6d 6d 65 64 20 76 61  |re-programmed va|
000003f0  72 69 61 62 6c 65 73 20  6f 66 20 77 68 69 63 68  |riables of which|
00000400  20 62 6c 61 63 6b 25 20  69 73 20 6f 6e 65 2e 20  | black% is one. |
00000410  54 68 65 20 6e 65 78 74  20 70 61 72 61 6d 65 74  |The next paramet|
00000420  65 72 73 20 73 74 61 74  65 20 74 68 65 20 73 74  |ers state the st|
00000430  61 72 74 20 61 6e 64 20  65 6e 64 20 70 6f 73 69  |art and end posi|
00000440  74 69 6f 6e 73 20 6f 66  20 74 68 65 20 6c 69 6e  |tions of the lin|
00000450  65 2e 0a 0a 53 74 65 70  20 34 29 0a 0a 44 6f 75  |e...Step 4)..Dou|
00000460  62 6c 65 20 63 6c 69 63  6b 20 6f 6e 20 74 68 65  |ble click on the|
00000470  20 69 63 6f 6e 2d 62 61  72 20 69 6e 66 6f 20 74  | icon-bar info t|
00000480  6f 20 67 65 74 20 74 68  65 20 73 74 61 74 69 73  |o get the statis|
00000490  74 69 63 73 20 61 62 6f  75 74 20 74 68 65 20 70  |tics about the p|
000004a0  72 6f 67 72 61 6d 2e 20  46 69 6c 6c 20 69 6e 20  |rogram. Fill in |
000004b0  74 68 69 73 20 66 6f 72  6d 20 61 73 20 73 68 6f  |this form as sho|
000004c0  77 6e 20 3a 2d 0a 0a 20  20 50 72 6f 67 72 61 6d  |wn :-..  Program|
000004d0  20 4e 61 6d 65 20 3a 20  21 43 69 72 63 6c 65 0a  | Name : !Circle.|
000004e0  20 20 20 20 20 20 20 50  75 72 70 6f 73 65 20 3a  |       Purpose :|
000004f0  20 44 72 61 77 20 61 20  63 69 72 63 6c 65 20 69  | Draw a circle i|
00000500  6e 20 61 20 77 69 6e 64  6f 77 0a 20 20 20 20 20  |n a window.     |
00000510  20 20 20 41 75 74 68 6f  72 20 3a 20 4d 79 20 4e  |   Author : My N|
00000520  61 6d 65 0a 20 20 20 20  20 20 20 56 65 72 73 69  |ame.       Versi|
00000530  6f 6e 20 3a 20 31 2e 30  30 0a 0a 53 65 6c 65 63  |on : 1.00..Selec|
00000540  74 20 43 6f 6d 6d 61 6e  64 20 3a 20 4f 50 45 4e  |t Command : OPEN|
00000550  57 49 4e 44 4f 57 20 55  6e 74 69 74 6c 65 64 31  |WINDOW Untitled1|
00000560  0a 20 20 4d 65 6e 75 20  43 6f 6d 6d 61 6e 64 20  |.  Menu Command |
00000570  3a 20 45 4e 44 0a 41 64  6a 75 73 74 20 43 6f 6d  |: END.Adjust Com|
00000580  6d 61 6e 64 20 3a 20 50  52 4f 43 63 69 72 63 6c  |mand : PROCcircl|
00000590  65 0a 0a 54 68 69 73 20  77 69 6c 6c 20 6e 6f 77  |e..This will now|
000005a0  20 63 61 75 73 65 20 74  68 65 20 77 69 6e 64 6f  | cause the windo|
000005b0  77 20 74 6f 20 6f 70 65  6e 20 75 70 6f 6e 20 61  |w to open upon a|
000005c0  20 73 65 6c 65 63 74 20  63 6f 6d 6d 61 6e 64 20  | select command |
000005d0  61 6e 64 20 74 68 65 20  69 6e 66 6f 72 6d 61 74  |and the informat|
000005e0  69 6f 6e 20 74 6f 20 62  65 20 64 69 73 70 6c 61  |ion to be displa|
000005f0  79 65 64 20 6f 6e 20 74  68 65 20 61 64 6a 75 73  |yed on the adjus|
00000600  74 20 63 6f 6d 6d 61 6e  64 2e 20 54 68 65 20 70  |t command. The p|
00000610  72 6f 67 72 61 6d 20 77  69 6c 6c 20 74 65 72 6d  |rogram will term|
00000620  69 6e 61 74 65 20 77 68  65 6e 20 74 68 65 20 6d  |inate when the m|
00000630  65 6e 75 20 62 75 74 74  6f 6e 20 69 73 20 73 65  |enu button is se|
00000640  6c 65 63 74 65 64 2e 0a  0a 54 68 65 20 70 72 6f  |lected...The pro|
00000650  67 72 61 6d 20 63 61 6e  20 6e 6f 77 20 62 65 20  |gram can now be |
00000660  73 61 76 65 64 20 6f 75  74 20 61 73 20 21 43 69  |saved out as !Ci|
00000670  72 63 6c 65 20 61 6e 64  20 72 75 6e 2e 0a 0a 53  |rcle and run...S|
00000680  74 65 70 20 35 29 0a 0a  4e 6f 77 20 63 72 65 61  |tep 5)..Now crea|
00000690  74 65 20 61 20 6e 65 77  20 6d 65 6e 75 20 61 6e  |te a new menu an|
000006a0  64 20 61 64 64 20 74 77  6f 20 6e 65 77 20 65 6e  |d add two new en|
000006b0  74 72 69 65 73 20 74 6f  20 74 68 69 73 2e 20 43  |tries to this. C|
000006c0  68 61 6e 67 65 20 74 68  65 20 69 6e 66 6f 72 6d  |hange the inform|
000006d0  61 74 69 6f 6e 20 61 73  20 73 68 6f 77 6e 0a 0a  |ation as shown..|
000006e0  46 69 72 73 74 0a 2d 2d  2d 2d 2d 0a 0a 45 6e 74  |First.-----..Ent|
000006f0  72 79 20 4e 61 6d 65 20  3a 20 49 6e 66 6f 0a 53  |ry Name : Info.S|
00000700  65 6c 65 63 74 20 74 68  65 20 49 6e 66 6f 20 42  |elect the Info B|
00000710  6f 78 20 72 61 64 69 6f  20 69 63 6f 6e 2e 0a 0a  |ox radio icon...|
00000720  53 65 63 6f 6e 64 0a 0a  45 6e 74 72 79 20 4e 61  |Second..Entry Na|
00000730  6d 65 20 3a 20 43 6f 6c  6f 75 72 0a 53 65 6c 65  |me : Colour.Sele|
00000740  63 74 20 74 68 65 20 43  6f 6c 6f 75 72 73 20 72  |ct the Colours r|
00000750  61 64 69 6f 20 69 63 6f  6e 0a 45 6e 74 72 79 20  |adio icon.Entry |
00000760  49 6e 66 6f 72 6d 61 74  69 6f 6e 20 3a 20 62 6c  |Information : bl|
00000770  61 63 6b 25 0a 0a 54 68  69 72 64 0a 0a 45 6e 74  |ack%..Third..Ent|
00000780  72 79 20 4e 61 6d 65 20  3a 20 51 75 69 74 0a 53  |ry Name : Quit.S|
00000790  65 6c 65 63 74 69 6f 6e  20 43 6f 6d 6d 61 6e 64  |election Command|
000007a0  20 3a 20 45 4e 44 0a 0a  53 74 65 70 20 36 29 0a  | : END..Step 6).|
000007b0  0a 44 6f 75 62 6c 65 20  63 6c 69 63 6b 20 6f 6e  |.Double click on|
000007c0  20 74 68 65 20 55 6e 74  69 74 6c 65 64 31 20 77  | the Untitled1 w|
000007d0  69 6e 64 6f 77 20 61 6e  64 20 65 6e 74 65 72 20  |indow and enter |
000007e0  69 6e 20 74 68 65 20 4d  65 6e 75 20 63 6f 6d 6d  |in the Menu comm|
000007f0  61 6e 64 20 73 65 63 74  69 6f 6e 20 3a 2d 0a 0a  |and section :-..|
00000800  4f 50 45 4e 4d 45 4e 55  20 55 6e 74 69 74 6c 65  |OPENMENU Untitle|
00000810  64 31 2c 4d 4f 55 53 45  50 4f 53 58 2d 36 34 2c  |d1,MOUSEPOSX-64,|
00000820  4d 4f 55 53 45 50 4f 53  59 2b 33 32 0a 0a 41 67  |MOUSEPOSY+32..Ag|
00000830  61 69 6e 20 74 68 65 20  70 72 6f 67 72 61 6d 20  |ain the program |
00000840  63 61 6e 20 62 65 20 73  61 76 65 64 20 61 6e 64  |can be saved and|
00000850  20 72 75 6e 0a 0a 0a 54  68 69 6e 67 73 20 74 6f  | run...Things to|
00000860  20 74 72 79 0a 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  | try.-----------|
00000870  2d 2d 0a 0a 4f 74 68 65  72 20 6d 65 6e 75 20 69  |--..Other menu i|
00000880  74 65 6d 73 20 63 61 6e  20 62 65 20 61 64 64 65  |tems can be adde|
00000890  64 20 66 6f 72 20 70 72  69 6e 74 69 6e 67 20 74  |d for printing t|
000008a0  68 65 20 77 69 6e 64 6f  77 2c 20 6f 72 20 73 61  |he window, or sa|
000008b0  76 69 6e 67 20 69 74 20  6f 75 74 20 61 73 20 61  |ving it out as a|
000008c0  20 64 72 61 77 20 66 69  6c 65 2e 0a 46 6f 72 20  | draw file..For |
000008d0  74 68 69 73 20 70 75 72  70 6f 73 65 20 75 73 65  |this purpose use|
000008e0  20 65 69 74 68 65 72 20  74 68 65 20 50 52 49 4e  | either the PRIN|
000008f0  54 57 49 4e 44 4f 57 20  63 6f 6d 6d 61 6e 64 20  |TWINDOW command |
00000900  6f 72 20 74 68 65 20 53  41 56 45 44 52 41 57 20  |or the SAVEDRAW |
00000910  63 6f 6d 6d 61 6e 64 2e                           |command.|
00000918