PROGRAM PhrasenDreschMachine(input,output);
(* V-1.01   (16-APR-88)   B.Glavina *)
(* V-1.00   (18-JUL-87)             *)

CONST
  MaxNumWord=20;
  StrLen=18; (* Bei Aenderung Anpassungen noetig *)
  left=^S; right=^D; up=^E; down=^X;
TYPE
  CharString= ARRAY [1..StrLen] OF char;
VAR
  Spinning: ARRAY [1..3] OF boolean;
  WindowX: ARRAY [1..3] OF integer;
  WindowY: integer;
  Words: ARRAY [1..3,1..MaxNumWord] OF CharString;
  WordPointer: ARRAY [1..3] OF integer;
  MaxWord: ARRAY [1..3] OF integer;
  ende: boolean;
  k: char;
  i: integer;

PROCEDURE SignOn_Menu;
  BEGIN
  ClrScr;
  Writeln('         Phrasen-Dresch-Maschine     V-1.01   (16-APR-88)');
  Writeln('');
  Writeln('');
  Writeln('******************************************************************');
  Writeln('*                    **                    **                    *');
  Writeln('*                    **                    **                    *');
  Writeln('*                    **                    **                    *');
  Writeln('******************************************************************');
  Writeln('          1                     2                     3');
  Writeln('');
  Writeln('');
  Writeln('Stop mit Leertaste');
  Writeln('Einzelstart mit 1, 2 oder 3; Gesamtstart mit 0');
  Writeln('');
  Writeln('Bei Stillstand: Pfeiltasten zur Einzelschrittsteuerung');
  Writeln('');
  Writeln('Aufhoeren mit X');
  END; (* SignOn_Menu *)

FUNCTION GetKey:integer;
(* liefert Code der gedr}ckten Taste oder 0 (wenn keine gedr}ckt ist) *)
  BEGIN getkey:=Bdos(6,255) END;

FUNCTION NextKey: char;
  VAR i,j: integer;
  BEGIN
  FOR i:=1 TO 3 DO
    IF Spinning[i] THEN
      BEGIN
      WordPointer[i]:=(WordPointer[i] MOD MaxWord[i])+1;
      GotoXY(WindowX[i],WindowY);
      FOR j:=1 TO StrLen DO Write(Words[i,WordPointer[i]][j]);
      END;
  NextKey:=chr(GetKey);
  END; (* NextKey *)

PROCEDURE Frame(i: integer; c: char);
  VAR z: integer;
  BEGIN
  GotoXY(WindowX[i]-1,WindowY-1);
  FOR z:=1 TO StrLen+2 DO Write(c);
  GotoXY(WindowX[i]-1,WindowY); Write(c);
  GotoXY(WindowX[i]+StrLen,WindowY); Write(c);
  GotoXY(WindowX[i]-1,WindowY+1);
  FOR z:=1 TO StrLen+2 DO Write(c);
  END; (* Frame *)

PROCEDURE Init;
  BEGIN
  WindowX[1]:=3; WindowX[2]:=25; WindowX[3]:=47; WindowY:=6;
  WordPointer[1]:=-1; WordPointer[2]:=-1; WordPointer[3]:=-1;
  Spinning[1]:=true; Spinning[2]:=true; Spinning[3]:=true;
  Words[1, 1]:='kreative          ';
  Words[1, 2]:='permanente        ';
  Words[1, 3]:='echte             ';
  Words[1, 4]:='konstruktive      ';
  Words[1, 5]:='emanzipatorische  ';
  Words[1, 6]:='ambivalente       ';
  Words[1, 7]:='qualifizierte     ';;
  Words[1, 8]:='systematisierte   ';
  Words[1, 9]:='funktionale       ';
  Words[1,10]:='integrierte       ';
  Words[1,11]:='machtvolle        ';
  Words[1,12]:='diese unsere      ';
  Words[1,13]:='fanatische        ';
  Words[1,14]:='unerschuetterliche';
  Words[1,15]:='erhabene          ';
  Words[1,16]:='tiefe             ';
  Words[1,17]:='innige            ';
  Words[1,18]:='mannhafte         ';
  Words[1,19]:='freudige          ';
  Words[1,20]:='abendlaendische   ';
  MaxWord[1]:=20;
  Words[2, 1]:='Organisations-    ';
  Words[2, 2]:='Fluktuations-     ';
  Words[2, 3]:='Beziehungs-       ';
  Words[2, 4]:='Innovations-      ';
  Words[2, 5]:='Koalitions-       ';
  Words[2, 6]:='Motivations-      ';
  Words[2, 7]:='Aktions-          ';
  Words[2, 8]:='Identifikations-  ';
  Words[2, 9]:='Kommunikations-   ';
  Words[2,10]:='Interpretations-  ';
  Words[2,11]:='Kultur-           ';
  Words[2,12]:='Erinnerungs-      ';
  Words[2,13]:='Seins-            ';
  Words[2,14]:='Wesens-           ';
  Words[2,15]:='Zukunfts-         ';
  Words[2,16]:='Schicksals-       ';
  Words[2,17]:='Vergangenheits-   ';
  Words[2,18]:='Geistes-          ';
  Words[2,19]:='Gewissens-        ';
  Words[2,20]:='Bildungs-         ';
  MaxWord[2]:=20;
  Words[3, 1]:='Praeferenz        ';
  Words[3, 2]:='Struktur          ';
  Words[3, 3]:='Relevanz          ';
  Words[3, 4]:='Phase             ';
  Words[3, 5]:='Potenz            ';
  Words[3, 6]:='Flexibilitaet     ';
  Words[3, 7]:='Akzeleration      ';
  Words[3, 8]:='Problematik       ';
  Words[3, 9]:='Tendenz           ';
  Words[3,10]:='Konzeption        ';
  Words[3,11]:='Aussage           ';
  Words[3,12]:='Besinnung         ';
  Words[3,13]:='Verantwortung     ';
  Words[3,14]:='Bewaeltigung      ';
  Words[3,15]:='Ergriffenheit     ';
  Words[3,16]:='Glaeubigkeit      ';
  Words[3,17]:='Verstrickung      ';
  Words[3,18]:='Gewissheit        ';
  Words[3,19]:='Verpfichtung      ';
  Words[3,20]:='Erhellung         ';
  MaxWord[3]:=20;
  i:=1; Frame(i,'#');
  ende:=false;
  END; (* Init *)

BEGIN
SignOn_Menu;
Init;
REPEAT
  k:=NextKey;
  CASE k OF
  ' ': BEGIN
    Frame(i,' '); Spinning[i]:=false;
    i:=(i MOD 3)+1; Frame(i,'#');
    END;
  '1','2','3': BEGIN
    Frame(i,' '); i:=ord(k)-ord('0');
    Spinning[i]:=true; Frame(i,'#');
    END;
  '0': BEGIN
    Spinning[1]:=true; Spinning[2]:=true; Spinning[3]:=true;
    END;
  left: BEGIN
    Frame(i,' '); i:=((i+1) MOD 3)+1;
    Frame(i,'#');
    END;
  right: BEGIN
    Frame(i,' '); i:=(i MOD 3)+1;
    Frame(i,'#');
    END;
  up:
    IF NOT Spinning[i] THEN BEGIN
      WordPointer[i]:=((WordPointer[i]-2) MOD MaxWord[i])+1;
      GotoXY(WindowX[i],WindowY);
      Write(Words[i,WordPointer[i]]);
      END;
  down:
    IF NOT Spinning[i] THEN BEGIN
      WordPointer[i]:=(WordPointer[i] MOD MaxWord[i])+1;
      GotoXY(WindowX[i],WindowY);
      Write(Words[i,WordPointer[i]]);
      END;
  'x','X',^[: BEGIN
    Frame(i,' ');
    GotoXY(1,18); ende:=true;
    END;
  END; (* CASE *)
UNTIL ende;
END.
