home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / sonderh1 / plotter.pas < prev    next >
Pascal/Delphi Source File  |  1987-03-13  |  6KB  |  192 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*                              PLOTTER.PAS                                *)
  3. (*                 Demonstration des Plottersimulators                     *)
  4. (*-------------------------------------------------------------------------*)
  5.  
  6. PROGRAM Plotter;
  7.  
  8. CONST
  9.   (*$I GPLOTCON.PAS *)
  10.  
  11. TYPE
  12.   (*$I GPLOTTYP.PAS *)
  13.   befehl = ARRAY[0..1] OF CHAR;
  14.  
  15. VAR
  16.   (*$I GPLOTVAR.PAS *)
  17.   bef       : befehl;
  18.   ch        : CHAR;
  19.   x, y      : INTEGER;
  20.   eingabe   : TEXT;
  21.   EingabeDatei, Pufferdatei: GPfName;
  22.  
  23. (*-------------------------------------------------------------------------*)
  24.  
  25. (*$I GPLOTSYS.PAS *)
  26. (*$I INTDDA.PAS *)         (* s. Artikel 'Vom Punkt zur dritten Dimension' *)
  27. (*$I BRESENH.PAS *)        (* s. Artikel 'Vom Punkt zur dritten Dimension' *)
  28. (*$I GPLOTGDP.PAS *)
  29. (*$I RELGRAF.PAS *)        (* s. Artikel 'Vom Punkt zur dritten Dimension' *)
  30.  
  31. (*-------------------------------------------------------------------------*)
  32.  
  33. PROCEDURE LoescheStatus;
  34.  
  35. BEGIN
  36.   GotoXY(9,22);   Write(' ':10);
  37.   GotoXY(27,22);  Write(' ':8);  GotoXY(45,22);  Write(' ':8);
  38. END;
  39.  
  40. (*-------------------------------------------------------------------------*)
  41.  
  42. PROCEDURE LiesKoordinaten (VAR x, y: INTEGER);
  43.  
  44. BEGIN
  45.   Read(eingabe, x);  GotoXY(27,22);  Write(x:8);
  46.   Read(eingabe, y);  GotoXY(45,22);  Write(y:8);
  47. END;
  48.  
  49. (*-------------------------------------------------------------------------*)
  50.  
  51. PROCEDURE LiesBefehl;
  52.  
  53. BEGIN
  54.   Read(eingabe, bef[0], bef[1], ch);  GotoXY(9,22);  Write(bef[0],bef[1]);
  55. END;
  56.  
  57. (*-------------------------------------------------------------------------*)
  58.  
  59. PROCEDURE LiesModus;
  60.  
  61. BEGIN
  62.   Read(eingabe, ch);
  63.   GotoXY(61,22);  Write(ch);
  64.   CASE ch OF
  65.     'S': GPsetzeMode(Setzen);
  66.     'L': GPsetzeMode(Loeschen);
  67.     'I': GPsetzeMode(Invertieren);
  68.   END;
  69. END;
  70.  
  71. (*-------------------------------------------------------------------------*)
  72.  
  73. PROCEDURE InterpretiereBefehl;
  74.  
  75. BEGIN
  76.   LiesBefehl;
  77.   CASE bef[0] OF
  78.     'B': CASE bef[1] OF
  79.            'X': BEGIN
  80.                   LiesKoordinaten(x, y);
  81.                   box(Pen_Xpos, Pen_Ypos, x, y);
  82.                 END;
  83.          END;
  84.     'C': CASE bef[1] OF
  85.            'L': GPloescheBlatt;
  86.            'I': BEGIN
  87.                   Read(eingabe, x);
  88.                   GotoXY(12,22);  Write(x:4);
  89.                   circle(Pen_Xpos, Pen_Ypos, x);
  90.                 END;
  91.          END;
  92.     'I': CASE bef[1] OF
  93.            'N': GPinvertiereBlatt;
  94.          END;
  95.     'L': BEGIN
  96.            LiesKoordinaten(x, y);
  97.            CASE bef[1] OF
  98.              'R': liner(x, y);
  99.              'A': linea(x, y);
  100.            END;
  101.          END;
  102.     'M': CASE bef[1] OF
  103.            'O': LiesModus;
  104.          ELSE
  105.            BEGIN
  106.              LiesKoordinaten(x, y);
  107.              CASE bef[1] OF
  108.                'R': mover(x, y);
  109.                'A': movea(x, y);
  110.              END;
  111.            END;
  112.          END;
  113.     'P': BEGIN
  114.            LiesKoordinaten(x, y);
  115.            CASE bef[1] OF
  116.              'R': pointr(x, y);
  117.              'A': point(x, y);
  118.            END;
  119.          END;
  120.   END;
  121.   IF NOT Eof(eingabe) THEN
  122.     ReadLn(eingabe);
  123.   LoescheStatus;
  124. END;
  125.  
  126. (*-------------------------------------------------------------------------*)
  127.  
  128. PROCEDURE Titel;
  129.  
  130. BEGIN
  131.   ClrScr;                                           (* Bildschirm loeschen *)
  132.   GotoXY(1,1);    Write('                  Plottersimulator Version 1.0');
  133.   GotoXY(1,3);    Write('Erkannte Befehle:');
  134.   GotoXY(5,5);    Write('CL.............Gesamtes Blatt loeschen');
  135.   GotoXY(5,6);    Write('IN.............Gesamtes Blatt invertieren');
  136.   GotoXY(5,7);    Write('MA x y.........Absolut positionieren');
  137.   GotoXY(5,8);    Write('MR x y.........Relativ positionieren');
  138.   GotoXY(5,9);    Write('PA x y.........Absolut Punkt setzen');
  139.   GotoXY(5,10);   Write('PR x y.........Relativ Punkt setzen');
  140.   GotoXY(5,11);   Write('LA x y.........Absolut Linie zeichnen');
  141.   GotoXY(5,12);   Write('LR x y.........Relativ Linie zeichnen');
  142.   GotoXY(5,13);   Write('BX x y.........Box v. akt. Pos. nach x y zeichnen');
  143.   GotoXY(5,14);   Write('CI r...........Kreis mit Radius r zeichnen');
  144.   GotoXY(5,15);   Write('MO m...........Zeichenmodus setzen : S = setzen');
  145.   GotoXY(42,16);  Write('L = loeschen');
  146.   GotoXY(42,17);  Write('I = invertieren');
  147.   GotoXY(1,18);   Write('Eingabedatei:');
  148.   GotoXY(1,19);   Write('Pufferdatei:');
  149.   GotoXY(1,22);   Write('Befehl:');
  150.   GotoXY(20,22);  Write('X-Wert:       0');
  151.   GotoXY(37,22);  Write('Y-Wert:       0');
  152.   GotoXY(54,22);  Write('Modus: S');
  153. END;
  154.  
  155. (*-------------------------------------------------------------------------*)
  156.  
  157. PROCEDURE Dateinamen;
  158.  
  159. BEGIN
  160.   GotoXY(15,18);  ReadLn(EingabeDatei);
  161.   IF Pos('.', EingabeDatei) = 0 THEN
  162.     EingabeDatei := Concat(EingabeDatei, '.PLT');
  163.   GotoXY(15,18);  Write(EingabeDatei);
  164.   GotoXY(15,19);  ReadLn(PufferDatei);
  165.   IF Length(PufferDatei)=0 THEN
  166.     PufferDatei := 'M:PLOTTER.BUF'
  167.   ELSE IF Pos('.', PufferDatei) = 0 THEN
  168.     PufferDatei := Concat(PufferDatei, '.BUF');
  169.   GotoXY(15,19);  Write(Pufferdatei);
  170. END;
  171.  
  172. (*-------------------------------------------------------------------------*)
  173.  
  174. BEGIN (* Plotter *)
  175.   Titel;
  176.   Dateinamen;
  177.   Assign(eingabe, EingabeDatei);
  178. (*$I-*)
  179.   ReSet(eingabe);
  180. (*$I+*)
  181.   IF IOResult <> 0 THEN
  182.     Halt;                                            (* Programm abbrechen *)
  183.   GPinit(Pufferdatei, FALSE);
  184.   WHILE NOT Eof(eingabe) DO
  185.     InterpretiereBefehl;
  186.   GPdruckeBlatt;
  187.   GPexit;
  188. END.
  189.  
  190. (*-------------------------------------------------------------------------*)
  191. (*                              Ende von PLOTTER.PAS                       *)
  192.