home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d008 / 2.ddi / RTSMP.PAK / TSTCOM.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-10-30  |  1.6 KB  |  81 lines

  1. library Comm;
  2.  
  3. uses wObjects, winTypes, winProcs, Strings;
  4.  
  5. var
  6.   DCB: TDCB;
  7.   CID:Integer;
  8.  
  9. function Dial(Comport, Dialtype, Number:PChar): integer; export;
  10.  
  11. var
  12.   P, Config, Num: PChar;
  13.   Struc: string;
  14.   i: integer;
  15. begin
  16.   Struc := #0;
  17.   GetMem(Config, 20);
  18.   GetMem(P, 255);
  19.   Strcopy(@Struc[1], Number);
  20.   Struc[0] := Char(StrLen(Number));
  21.   Struc := Struc+#0;
  22.   { Strip Routine }
  23.   i := 1;
  24.   while i <= length(Struc) do
  25.   begin
  26.     if (((Struc[i] < #48) or (Struc[i] > #57)) and ((Struc[i] <> ','))) then
  27.     begin
  28.       Delete(Struc, i, 1);
  29.       Dec(i);
  30.     end;
  31.     i := i+1;
  32.   end;
  33.   StrCopy(Config, Comport);
  34.   Config := StrCat(Config, ':12,n,8,1');
  35.   StrLCopy(P, Dialtype, 20);
  36.   P := StrCat(P, @Struc[1]);
  37.   P := StrCat(P, #13#10);
  38.   BuildCommDCB(Config, DCB);
  39.   if CID <= 0 then
  40.   begin
  41.     Cid := OpenComm(Comport, 1024, 1024);
  42.     if not(CID<0) then
  43.     begin
  44.       DCB.ID := CID;
  45.       SetCommState(DCB);
  46.       if WriteComm(CID, p, StrLen(P)) <= 0 then
  47.       begin
  48.         MessageBox(getfocus, 'Dial Error', 'Error', Mb_Ok);
  49.         Dial := 1; {return error}
  50.       end
  51.       else
  52.         Dial := 0; {return no error}
  53.     end;
  54.   end;
  55.   FreeMem(P, 255);
  56.   FreeMem(Config, 20);
  57. end;
  58.  
  59. function Hangup : bool; export;
  60. begin
  61.   if not(CID < 0) then
  62.   begin
  63.     WriteComm(CID, 'ATH'#13#10, 5);
  64.     If CloseComm(Cid) < 0 then
  65.     begin
  66.       MessageBox(GetFocus, 'Hangup Error', 'Error', Mb_Ok);
  67.       Hangup := bool(0);
  68.     end
  69.     else
  70.     begin
  71.       Cid := 0;
  72.       Hangup := bool(1);
  73.     end;
  74.   end;
  75. end;
  76.  
  77. Exports Dial index 1;
  78. Exports Hangup index 2;
  79.  
  80. begin
  81. end.