home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / COMAL3-1.DMS / in.adf / Tutorial / Prg9.1 < prev   
Encoding:
Text File  |  1993-04-09  |  1.9 KB  |  104 lines

  1. // Program 9.1
  2.  
  3. USE CITWindow
  4. USE CITGadgets
  5. USE Turtle
  6. USE Figures
  7.  
  8. graphicscreen(0)
  9. ht
  10.  
  11. DIM TriangleGad OF ButtonGadget
  12. TriangleGad.Size(120,20)
  13. TriangleGad.Position(0,0)
  14. TriangleGad.Label("Triangle",INSIDE)
  15. TriangleGad.EventHandler(TriangleEvent())
  16. ComalWindow.InsObject(TriangleGad,Error)
  17. PROC TriangleEvent(Id OF USHORT)
  18.   clearscreen
  19.   triangle
  20. ENDPROC TriangleEvent
  21.  
  22. DIM SquareGad OF ButtonGadget
  23. SquareGad.Size(120,20)
  24. SquareGad.Position(120,0)
  25. SquareGad.Label("Square",INSIDE)
  26. SquareGad.EventHandler(SquareEvent())
  27. ComalWindow.InsObject(SquareGad,Error)
  28. PROC SquareEvent(Id OF USHORT)
  29.   clearscreen
  30.   square
  31. ENDPROC SquareEvent
  32.  
  33. DIM PentagonGad OF ButtonGadget
  34. PentagonGad.Size(120,20)
  35. PentagonGad.Position(240,0)
  36. PentagonGad.Label("Pentagon",INSIDE)
  37. PentagonGad.EventHandler(PentagonEvent())
  38. ComalWindow.InsObject(PentagonGad,Error)
  39. PROC PentagonEvent(Id OF USHORT)
  40.   clearscreen
  41.   pentagon
  42. ENDPROC PentagonEvent
  43.  
  44. DIM HexagonGad OF ButtonGadget
  45. HexagonGad.Size(120,20)
  46. HexagonGad.Position(360,0)
  47. HexagonGad.Label("Hexagon",INSIDE)
  48. HexagonGad.EventHandler(HexagonEvent())
  49. ComalWindow.InsObject(HexagonGad,Error)
  50. PROC HexagonEvent(Id OF USHORT)
  51.   clearscreen
  52.   hexagon
  53. ENDPROC HexagonEvent
  54.  
  55. DIM Close OF ButtonGadget
  56. Close.Size(138,20)
  57. Close.Position(480,0)
  58. Close.Label("STOP",INSIDE)
  59. ComalWindow.InsObject(Close,Error)
  60.  
  61. IF Error THEN
  62.   PRINT "Could not create one or more gadgets"
  63. ENDIF
  64.  
  65. viewport(0,width-1,0,height-21)
  66.  
  67. WHILE NOT Close.Pressed DO WAIT
  68.  
  69. textscreen
  70.  
  71.  
  72. // ************* end of main program **********
  73.  
  74. MODULE Figures
  75.  
  76.   USE Turtle
  77.  
  78.   EXPORT triangle,square,pentagon,hexagon
  79.  
  80.   PROC triangle
  81.     Polygon(3)
  82.   ENDPROC triangle
  83.  
  84.   PROC square
  85.     Polygon(4)
  86.   ENDPROC square
  87.  
  88.   PROC pentagon
  89.     Polygon(5)
  90.   ENDPROC pentagon
  91.  
  92.   PROC hexagon
  93.     Polygon(6)
  94.   ENDPROC hexagon
  95.  
  96.   PROC Polygon(n)
  97.     LOOP n TIMES
  98.       forward(50)
  99.       right(360/n)
  100.     ENDLOOP
  101.   ENDPROC Polygon
  102.  
  103. ENDMODULE Figures
  104.