home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / delite / miniterm / miniterm.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-04-01  |  19.4 KB  |  560 lines

  1. PROGRAM MINITERM;
  2. (*****************************************************************************
  3. Name:              MINITERM.PAS
  4. Version:           1.1
  5. Edit Datum:        1.3.1992
  6. Autor:             Frank Seidinger
  7. Kurzbeschreibung:  V24 Kommunikation unter deLite
  8. *****************************************************************************)
  9.  
  10. USES  Kernel, API, Dialogs, V24, DOS;
  11.  
  12. Type  MiniTermSettingsType = Record
  13.         MiniComPort   : ComPortType;
  14.         MiniBaudRate  : ComBaudType;
  15.         MiniDataBits  : ComBitsType;
  16.         MiniStopBits  : ComStopType;
  17.         MiniParity    : ComDataType;
  18.         MiniComBuffer : ComBuffType;
  19.         MiniComMode   : ComModeType;
  20.         MiniHandShake : Word;
  21.       End;
  22.  
  23. CONST ProjektName   = 'miniterm';             { so heissen alle Dateien  }
  24.       PaintColor    = yellow;
  25.       BackColor     = black;
  26.       Echo          = False;
  27.  
  28.       BaudRates     : array[ComBaudType] of ListString =
  29.                       ('110'  ,'150'   ,'300'   ,'600'   ,'1200'  ,'2400'  ,
  30.                        '4800' ,'9600'  ,'19200' ,'38400' ,'57600' ,'115200');
  31.  
  32.       ComPorts      : array[ComPortType] of ListString =
  33.                       ('COM1','COM2','COM3','COM4','User','NoCom');
  34.  
  35.       Parity        : array[ComDataType] of ListString =
  36.                       ('Space','Odd','Mark','Even','None');
  37.  
  38.       FIFO          : array[ComModeType] of ListString =
  39.                       ('Kein','Aus','FIFO 1','FIFO 4','FIFO 8','FIFO 14');
  40.  
  41.       TermSettings  : MiniTermSettingsType = (
  42.                       MiniComPort   : Com1;
  43.                       MiniBaudRate  : b1200;
  44.                       MiniDataBits  : d8;
  45.                       MiniStopBits  : s1;
  46.                       MiniParity    : NoParity;
  47.                       MiniComBuffer : KB1;
  48.                       MiniComMode   : Normal;
  49.                       MiniHandShake : 0
  50.                       );
  51.  
  52. VAR   LaunchResult  : integer;
  53.       MyEvent       : EventTyp;
  54.       StillRunning  : boolean;
  55.  
  56.       PosX, PosY    : Integer;
  57.       MaxX, MaxY    : Integer;
  58.  
  59.       ComBaudPtr    : ComBaudType;
  60.       ComPortPtr    : ComPortType;
  61.       ComParityPtr  : ComDataType;
  62.       ComFIFOPtr    : ComModeType;
  63.  
  64.       SaveFlag      : Boolean;
  65.  
  66. { ***************
  67.   Hilfsprozeduren
  68.   *************** }
  69.  
  70.   function CompareMemory(Location1, Location2 : Pointer; Len : Word) : Integer;
  71.   Var Result : Integer;
  72.   begin
  73.     while (Len <> 0) do
  74.       begin
  75.         Result := Byte(Location2^) - Byte(Location1^);
  76.         if result <> 0 Then
  77.           begin
  78.             CompareMemory := Result;
  79.             exit;
  80.           end;
  81.         inc(LongInt(Location1));
  82.         inc(LongInt(Location2));
  83.         dec(Len);
  84.       end;
  85.     CompareMemory := 0;
  86.   end;
  87.  
  88. { **************************************************
  89.   Speichert und lädt die Einstellungen des Com-Ports
  90.   ************************************************** }
  91.  
  92.   procedure SaveSetup;
  93.   Var TempStr : String;
  94.   begin
  95.     SetCursor(LoadCursor(HourGlassCursor));
  96.     SetInitFileName   ('ComPort','Device'   ,ComPorts[TermSettings.MiniComPort]);
  97.     SetInitFileName   ('ComPort','Baudrate' ,BaudRates[TermSettings.MiniBaudRate]);
  98.     SetInitFileName   ('ComPort','Parity'   ,Parity[TermSettings.MiniParity]);
  99.     SetInitFileInteger('ComPort','Databits' ,Ord(TermSettings.MiniDataBits)+5);
  100.     SetInitFileInteger('ComPort','Stopbits' ,Ord(TermSettings.MiniStopBits)+1);
  101.     SetInitFileInteger('ComPort','Buffer'   ,Ord(TermSettings.MiniComBuffer));
  102.     SetInitFileString ('ComPort','FIFOMode' ,FIFO[TermSettings.MiniComMode]);
  103.     SetInitFileInteger('ComPort','Handshake',TermSettings.MiniHandShake);
  104.     SetCursor(LoadCursor(DefaultCursor));
  105.   end;
  106.  
  107.   procedure ReadSetup;
  108.   var TempStr : String;
  109.       I       : Integer;
  110.       MyLong  : LongInt;
  111.   begin
  112.     If GetInitFileName('ComPort','Device',TempStr) Then
  113.       For I := Ord(Com1) to Ord(UserCom) do
  114.         If (ComPorts[ComPortType(I)] = TempStr) Then TermSettings.MiniComPort := ComPortType(I);
  115.  
  116.     If GetInitFileName('ComPort','Baudrate',TempStr) Then
  117.       For I := Ord(b110) to Ord(b115200) do
  118.         If (BaudRates[ComBaudType(I)] = TempStr) Then TermSettings.MiniBaudRate := ComBaudType(I);
  119.  
  120.     If GetInitFileName('ComPort','Parity',TempStr) Then
  121.       For I := Ord(Space) to Ord(NoParity) do
  122.         If (Parity[ComDataType(I)] = TempStr) Then TermSettings.MiniParity := ComDataType(I);
  123.  
  124.     If (GetInitFileInteger('ComPort','DataBits',MyLong) and
  125.        (MyLong >= 5) and
  126.        (MyLong <= 8)) Then
  127.       TermSettings.MiniDataBits := ComBitsType(MyLong-5);
  128.  
  129.     If (GetInitFileInteger('ComPort','StopBits',MyLong) and
  130.        (MyLong >= 1) and
  131.        (MyLong <= 2)) Then
  132.       TermSettings.MiniStopBits := ComStopType(MyLong-1);
  133.  
  134.     If (GetInitFileInteger('ComPort','Buffer',MyLong) and
  135.        (MyLong >= Ord(Kb1)) and
  136.        (MyLong <= Ord(Kb16))) Then
  137.       TermSettings.MiniComBuffer := ComBuffType(MyLong);
  138.  
  139.     If GetInitFileString('ComPort','FIFOMode',TempStr) Then
  140.       For I := Ord(Normal) to Ord(FIFO14) do
  141.         If (FIFO[ComModeType(I)] = TempStr) Then TermSettings.MiniComMode := ComModeType(I);
  142.  
  143.     If GetInitFileInteger('ComPort','HandShake',MyLong) Then TermSettings.MiniHandShake := Word(MyLong);
  144.   end;
  145.  
  146. { *********************************************************
  147.   GetFirst/GetNext Prozeduren für den Konfigurations Dialog
  148.   ********************************************************* }
  149.  
  150.   procedure GetNextBaud(var bd: ListString; var eol: boolean); far;
  151.   begin
  152.     eol := true;
  153.     if ComBaudPtr <= b38400 then
  154.       begin
  155.         bd := BaudRates[ComBaudPtr];
  156.         inc(ComBaudPtr);
  157.         eol := false;
  158.       end;
  159.   end;
  160.  
  161.   procedure GetFirstBaud(var bd: ListString; var eol: boolean); far;
  162.   begin
  163.     ComBaudPtr := b110;
  164.     GetNextBaud(bd, eol);
  165.   end;
  166.  
  167.   procedure GetNextPort(var port : ListString; var eol : boolean); far;
  168.   begin
  169.     if ComPortPtr < NoCom Then
  170.       begin
  171.         port := ComPorts[ComPortPtr];
  172.         inc(ComPortPtr);
  173.         eol := false;
  174.       end
  175.     else eol := true;
  176.   end;
  177.  
  178.   procedure GetFirstPort(var port : ListString; var eol : boolean); far;
  179.   begin
  180.     ComPortPtr := Com1;
  181.     GetNextPort(port,eol);
  182.   end;
  183.  
  184.   procedure GetNextParity(var the_parity : ListString; var eol : boolean); far;
  185.   begin
  186.     if ComParityPtr <= NoParity Then
  187.       begin
  188.         the_parity := Parity[ComParityPtr];
  189.         inc(ComParityPtr);
  190.         eol := false;
  191.       end
  192.     else eol := true;
  193.   end;
  194.  
  195.   procedure GetFirstParity(var the_parity : ListString; var eol : boolean); far;
  196.   begin
  197.     ComParityPtr := Space;
  198.     GetNextParity(the_parity,eol);
  199.   end;
  200.  
  201.   procedure GetNextFIFO(var the_fifo : ListString; var eol : boolean); far;
  202.   begin
  203.     if ComFIFOPtr <= FIFO14 Then
  204.       begin
  205.         the_fifo := FIFO[ComFIFOPtr];
  206.         inc(ComFIFOPtr);
  207.         eol := false;
  208.       end
  209.     else eol := true;
  210.   end;
  211.  
  212.   procedure GetFirstFIFO(var the_fifo : ListString; var eol : boolean); far;
  213.   begin
  214.     ComFIFOPtr := normal;
  215.     GetNextFIFO(the_fifo,eol);
  216.   end;
  217.  
  218. { **********************************************************************
  219.   Der Konfiguratons Dialog für die Einstellungen der RS232 Schnittstelle
  220.   ********************************************************************** }
  221.  
  222.   procedure KonfigV24Handler(TheEvent : EventTyp); far;
  223.   var MYDLG    : PDLG;
  224.       TheStr   : String;
  225.   begin
  226.     MYDLG := TheEvent.DlgAdr;
  227.     if TheEvent.Class = DialogEvent then
  228.       Case TheEvent.MSG of
  229.         DLG_OK      : MYDLG^.DestroyDialog;
  230.  
  231.         DLG_CANCEL  : Begin
  232.                         MYDLG^.flags := MYDLG^.flags or MF_CANCELLED;
  233.                         MYDLG^.DestroyDialog;
  234.                       End;
  235.         DLG_BUTTON  : If TheEvent.ID = 201 Then
  236.                         Begin
  237.                           SaveFlag := true;
  238.                           MYDLG^.DestroyDialog;
  239.                         End;
  240.       End;
  241.   End;
  242.  
  243.   procedure KonfigV24;
  244.   var MyDialog   : Dialog;
  245.       MyCombo    : PComboBox;
  246.       MyButton   : PButton;
  247.       MyLabel    : PLabelText;
  248.       MyRadios   : PRadioButtons;
  249.       MyFrame    : PLabelFrame;
  250.       MyCheck    : PCheckBox;
  251.       MySettings : MiniTermSettingsType;
  252.       TempStr    : String;
  253.       Ready      : boolean;
  254.   begin
  255.     MySettings := TermSettings;
  256.     SaveFlag   := False;
  257.  
  258.     MyDialog.Init(40*FontX, 18*FontY, MF_CAPTION, KonfigV24Handler);
  259.     MyDialog.SetCaption('RS232 Konfiguration');
  260.     MyDialog.SetTopic('Konfig');
  261.  
  262.     { Communication Port beschriften und Auswahl Element installieren }
  263.     new(MyLabel, Init(   FontX,   FontY + 4,   0, 'COM-Port'));
  264.     MyDialog.AddItem(MyLabel);
  265.     new(MyCombo, Init(10*FontX,   FontY, 8, 4, 101, GetFirstPort, GetNextPort));
  266.     MyDialog.AddItem(MyCombo);
  267.     MyCombo^.Select(ComPorts[TermSettings.MiniComPort]);
  268.  
  269.     { Baudrate beschriften und Auswahl Element installieren }
  270.     new(MyLabel, Init(   FontX, 3*FontY + 4,   0, 'Baudrate'));
  271.     MyDialog.AddItem(MyLabel);
  272.     new(MyCombo, Init(10*FontX, 3*FontY, 8, 4, 102, GetFirstBaud, GetNextBaud));
  273.     MyDialog.AddItem(MyCombo);
  274.     MyCombo^.Select(BaudRates[TermSettings.MiniBaudRate]);
  275.  
  276.     { Parität beschriften und Auswahl Element installieren }
  277.     new(MyLabel, Init(   FontX, 5*FontY + 4,   0, 'Parität'));
  278.     MyDialog.AddItem(MyLabel);
  279.     new(MyCombo, Init(10*FontX, 5*FontY, 8, 4, 103, GetFirstParity, GetNextParity));
  280.     MyDialog.AddItem(MyCombo);
  281.     MyCombo^.Select(Parity[TermSettings.MiniParity]);
  282.  
  283.     { FIFO Modus beschriften un Auswahl Element installieren }
  284.     new(MyLabel, Init(   FontX, 7*FontY + 4,   0, '16550'));
  285.     MyDialog.AddItem(MyLabel);
  286.     new(MyCombo, Init(10*FontX, 7*FontY, 8, 4, 104, GetFirstFIFO, GetNextFIFO));
  287.     MyDialog.AddItem(MyCombo);
  288.     MyCombo^.Select(FIFO[TermSettings.MiniComMode]);
  289.  
  290.     { Datenbits beschriften und Auswahl Element installieren }
  291.     new(MyRadios, Init(   FontX, 10*FontY, 20*FontX, 2*FontY, 109, 'Datenbits:',
  292.      new(PRadioButton, Init(   FontX,   FontY div 2 + 2, 112, '7 Bit' ,
  293.       new(PRadioButton, Init(10*FontX,   FontY div 2 + 2, 113, '8 Bit', NIL))))));
  294.     MyDialog.AddItem(MyRadios);
  295.     MyRadios^.CheckButton(110+Ord(TermSettings.MiniDataBits));
  296.  
  297.     { Stopbits beschriften und Auswahl Element installieren }
  298.     new(MyRadios, Init(   FontX, 13*FontY, 20*FontX, 2*FontY, 119, 'Stopbits:',
  299.      new(PRadioButton, Init(   FontX,   FontY div 2 + 2, 120, '1 Bit' ,
  300.       new(PRadioButton, Init(10*FontX,   FontY div 2 + 2, 121, '2 Bit', NIL))))));
  301.     MyDialog.AddItem(MyRadios);
  302.     MyRadios^.CheckButton(120+Ord(TermSettings.MiniStopBits));
  303.  
  304.     { Hand-Shake beschriften und Auswahl Element installieren }
  305.     new(MyFrame, Init(   FontX, 16*FontY, 38*FontX, 2*FontY,   0,'Hand-Shake'));
  306.     MyDialog.AddItem(MyFrame);
  307.     new(MyCheck, Init( 2*FontX, 16*FontY + (1*FontY) div 2 + 2, 130, 'XON/XOFF'));
  308.     MyDialog.AddItem(MyCheck);
  309.     If ((TermSettings.MiniHandShake and XON) <> 0) Then MyCheck^.Check;
  310.     new(MyCheck, Init(16*FontX, 16*FontY + (1*FontY) div 2 + 2, 131, 'CTS/RTS'));
  311.     MyDialog.AddItem(MyCheck);
  312.     If ((TermSettings.MiniHandShake and CTS) <> 0) Then MyCheck^.Check;
  313.     new(MyCheck, Init(28*FontX, 16*FontY + (1*FontY) div 2 + 2, 132, 'DSR/DTR'));
  314.     MyDialog.AddItem(MyCheck);
  315.     If ((TermSettings.MiniHandShake and DSR) <> 0) Then MyCheck^.Check;
  316.  
  317.     { Puffergröße beschriften und Auswahl Element installieren }
  318.     new(MyRadios, Init(23*FontX,  9*FontY, 16*FontX,  6*FontY, 139, 'Puffergröße:',
  319.      new(PRadioButton, Init(   FontX,   FontY div 2 + 2, 140, ' 1 Kilo Byte',
  320.       new(PRadioButton, Init(   FontX, 3*FontY div 2 + 2, 141, ' 2 Kilo Byte',
  321.        new(PRadioButton, Init(   FontX, 5*FontY div 2 + 2, 142, ' 4 Kilo Byte',
  322.         new(PRadioButton, Init(   FontX, 7*FontY div 2 + 2, 143, ' 8 Kilo Byte',
  323.          new(PRadioButton, Init(   FontX, 9*FontY div 2 + 2, 144, '16 Kilo Byte', NIL))))))))))));
  324.     MyDialog.AddItem(MyRadios);
  325.     MyRadios^.CheckButton(140 + Ord(TermSettings.MiniComBuffer));
  326.  
  327.     new(MyButton, Init(23*FontX, ( 2*FontY) div 2, 16*FontX, 2*FontY, 200,'OK'));
  328.     MyButton^.MakeDefaultItem;
  329.     MyDialog.AddItem(MyButton);
  330.  
  331.     new(MyButton, Init(23*FontX, ( 7*FontY) div 2, 16*FontX, 2*FontY, 201,'Save'));
  332.     MyDialog.AddItem(MyButton);
  333.  
  334.     new(MyButton, Init(23*FontX, (12*FontY) div 2, 16*FontX, 2*FontY, 202,'Cancel'));
  335.     MyButton^.MakeCancelItem;
  336.     MyDialog.AddItem(MyButton);
  337.  
  338.     MyDialog.Show;
  339.  
  340.     Ready := False;
  341.     Repeat
  342.       MyDialog.DoDialog;
  343.       if MyDialog.WasNotCancelled then
  344.         begin
  345.           MyCombo := MyDialog.FindDlgItem(101);
  346.           TempStr := MyCombo^.GetSelected;
  347.           For ComPortPtr := Com1 to UserCom do
  348.             If (TempStr = ComPorts[ComPortPtr]) Then MySettings.MiniComPort := ComPortPtr;
  349.  
  350.           MyCombo := MyDialog.FindDlgItem(102);
  351.           TempStr := MyCombo^.GetSelected;
  352.           For ComBaudPtr := b110 to b115200 do
  353.             If (TempStr = BaudRates[ComBaudPtr]) Then MySettings.MiniBaudRate := ComBaudPtr;
  354.  
  355.           MyCombo := MyDialog.FindDlgItem(103);
  356.           TempStr := MyCombo^.GetSelected;
  357.           For ComParityPtr := Space to NoParity do
  358.             If (TempStr = Parity[ComParityPtr]) Then MySettings.MiniParity := ComParityPtr;
  359.  
  360.           MyCombo := MyDialog.FindDlgItem(104);
  361.           TempStr := MyCombo^.GetSelected;
  362.           For ComFIFOPtr := Normal to FIFO14 do
  363.             If (TempStr = FIFO[ComFIFOPtr]) Then MySettings.MiniComMode := ComFIFOPtr;
  364.  
  365.           MyRadios := MyDialog.FindDlgItem(109);
  366.           MySettings.MiniDataBits := ComBitsType(MyRadios^.WhosChecked - 110);
  367.  
  368.           MyRadios := MyDialog.FindDlgItem(119);
  369.           MySettings.MiniStopBits := ComStopType(MyRadios^.WhosChecked - 120);
  370.  
  371.           MyRadios := MyDialog.FindDlgItem(139);
  372.           MySettings.MiniComBuffer := ComBuffType(MyRadios^.WhosChecked - 140);
  373.  
  374.           If (CompareMemory(@MySettings,@TermSettings,SizeOf(MiniTermSettingsType)) <> 0) Then
  375.             begin
  376.               If OpenCom(MySettings.MiniComPort,
  377.                          MySettings.MiniBaudRate,
  378.                          MySettings.MiniDataBits,
  379.                          MySettings.MiniParity,
  380.                          MySettings.MiniStopBits,
  381.                          MySettings.MiniComMode,
  382.                          MySettings.MiniComBuffer) Then
  383.                 begin
  384.                   TermSettings := MySettings;
  385.                   Ready := True;
  386.                 end
  387.               else ErrWindow(100,100,'Hardware nicht verfügbar!');
  388.             end
  389.           else Ready := True;
  390.           TermSettings.MiniHandShake := 0;
  391.           MyCheck := MyDialog.FindDlgItem(130);
  392.           If MyCheck^.IsChecked Then TermSettings.MiniHandShake := TermSettings.MiniHandShake + XON;
  393.  
  394.           MyCheck := MyDialog.FindDlgItem(131);
  395.           If MyCheck^.IsChecked Then TermSettings.MiniHandShake := TermSettings.MiniHandShake + CTS;
  396.  
  397.           MyCheck := MyDialog.FindDlgItem(132);
  398.           If MyCheck^.IsChecked Then TermSettings.MiniHandShake := TermSettings.MiniHandShake + DSR;
  399.  
  400.           SetHandShake(TermSettings.MiniHandShake);
  401.  
  402.           If SaveFlag Then
  403.             SaveSetup;
  404.         end
  405.       else Ready := True;
  406.     Until Ready;
  407.     MyDialog.Done;
  408.   end;
  409.  
  410. { *********************************************************************
  411.   Hier bitte die Prozedur kodieren, die die Meldung auf das G behandelt
  412.   ********************************************************************* }
  413.  
  414.   Procedure Meldung;
  415.   Begin
  416.     {
  417.     Write(#7);
  418.     }
  419.   End;
  420.  
  421. { ***********************************************************************
  422.   Fenster Prozeduren zum Aufbau eines Textbildschirmes bei Verwendung der
  423.   hochauflösenden Zeichenroutinen
  424.   *********************************************************************** }
  425.  
  426.   Procedure ClearTheScreen;
  427.   begin
  428.     ClearWindow;
  429.     PosX := 0;
  430.     PosY := 0;
  431.   end;
  432.  
  433.   Procedure ScrollUp;
  434.   Var X1,X2,Y1,Y2 : Integer;
  435.   Begin
  436.     X1 :=     0; X2 := 0;
  437.     Y1 := FontY; Y2 := 0;
  438.     BitBlit(x1,y1,x2,y2,Succ(PortMaxX),MaxY*FontY);
  439.     Bar(0,Pred(MaxY)*FontY,PortMaxX,MaxY*FontY,BackGndCol);
  440.   End;
  441.  
  442.   Procedure IncYPosition;
  443.   Begin
  444.     Inc(PosY);
  445.     if (PosY >= MaxY) Then
  446.       Begin
  447.         ScrollUp;
  448.         Dec(PosY);
  449.       End;
  450.   End;
  451.  
  452.   Procedure IncXPosition;
  453.   Begin
  454.     Inc(PosX);
  455.     If (PosX > MaxX) Then
  456.       Begin
  457.         PosX := 0;
  458.         IncYPosition;
  459.       End;
  460.   End;
  461.  
  462.   Procedure WriteBlank;
  463.   Var X1,X2,Y1,Y2 : Integer;
  464.   Begin
  465.     X1 := PosX*FontX; X2 := X1 + FontX;
  466.     Y1 := PosY*FontY; Y2 := Y1 + FontY;
  467.     Bar(X1,Y1,X2,Y2,BackGndCol);
  468.     IncXPosition;
  469.   End;
  470.  
  471.   Procedure WriteTTY(TheChar : Char);
  472.   Var OutString : String[1];
  473.   Begin
  474.     Case TheChar Of
  475.          #13   : PosX := 0;
  476.  
  477.          #10   : IncYPosition;
  478.  
  479.          #32   : WriteBlank;
  480.  
  481.          Else    Begin
  482.                    OutString := TheChar;
  483.                    Bar(PosX*FontX,PosY*FontY,Succ(PosX)*FontX,Succ(PosY)*FontY,BackGndCol);
  484.                    OutTextAPI(PosX*FontX,PosY*FontY,OutString,PaintColor,0);
  485.                    IncXPosition;
  486.                  End;
  487.       End; { Case }
  488.   End;
  489.  
  490. { ************************************************************************
  491.   Der Event Handler der Haupt Applikation. Achtung, diese Prozedur ist nur
  492.   dann aktiv, wenn kein Dialog und kein Menü geöffnet ist.
  493.   ************************************************************************ }
  494.  
  495.   Procedure HandleMsg(MyMessage: EventTyp); far;
  496.   Var MyChar : Char;
  497.   Begin
  498.     With MyMessage Do
  499.       Case Class Of
  500.         Menu    : begin
  501.                     Case MenuItemID of
  502.                        0   : StillRunning := false;  { Ende }
  503.                        101 : ClearTheScreen;
  504.                        201 : KonfigV24;
  505.                     end;
  506.                   End;
  507.  
  508.         Void    : Begin
  509.                     If IsComDataAvail Then
  510.                       Begin
  511.                         HideMouse;
  512.                         MyChar := Char(GetComData);
  513.                         If MyChar in ['g','G'] Then
  514.                           Meldung;
  515.                         WriteTTY(MyChar);
  516.                         ShowMouse;
  517.                         { Do what ever you want to do }
  518.                       End;
  519.                   End;
  520.  
  521.         NormKey : If Not IsComDataAvail Then
  522.                     PutComData(Ord(Attrib));
  523.  
  524.     CtrlKey : If Not IsComDataAvail Then
  525.                     PutComData(Ord(Attrib)-96);
  526.       End; { Case Class }
  527.   End;
  528.  
  529. Begin
  530.   StillRunning := true;
  531.   LaunchResult := OpenMainApplication(HandleMsg,
  532.                                           APP_NOFONT,
  533.                                           ProjektName);
  534.   If LaunchResult = 0 then                { erfolgreich gestartet }
  535.   begin
  536.     ReadSetup;
  537.     OpenCom(TermSettings.MiniComPort,
  538.             TermSettings.MiniBaudRate,
  539.             TermSettings.MiniDataBits,
  540.             TermSettings.MiniParity,
  541.             TermSettings.MiniStopBits,
  542.             TermSettings.MiniComMode,
  543.             TermSettings.MiniComBuffer);
  544.     SetHandShake(TermSettings.MiniHandShake);
  545.     PosX := 0;
  546.     PosY := 0;
  547.     MaxX := PortMaxX div FontX;
  548.     MaxY := PortMaxY div FontY;
  549.     while StillRunning Do
  550.        begin
  551.         GetEvent(MyEvent);
  552.         DispatchMessage(MyEvent);
  553.       end;
  554.     CloseCom;
  555.     CloseMainApplication;
  556.   end
  557.   Else
  558.     Writeln('Programm kann nicht gestartet werden. Fehler: ',LaunchResult);
  559. End.
  560.