program dial;

{This program is written using Turbo Pascal.  It accepts user input to
dial the Hayes SmartModem 1200.  MS-DOS interrupts are used for RS232
communications, so even though this was written on a Tandy 2k, it shoul
work in the IBM and the host of compatables.  If you have trouble
communicating with the serial port, check and change as needed the
value assigned to DL in talk.  It selects the COM port which runs the modem}

{initialize for MS DOS interrupt call}
type
     regipak = record ax,bx,cx,dx,bp,di,ds,es,flags:integer;
     end;

var
    dm:byte;
    mypak: regipak;
    ah,al,bh,bl,ch,cl,dh,dl,bph,bpl,dih,dil,dsh,dsl: byte;
    cx,len,ct:integer;
    ir:byte;
    dialit,LAST,NUMBER,personal,prefix:string[40];
    dummy,digit:char;

procedure talk;
{Send characters to the modem}
begin
     with mypak do
     begin
     ax := ah shl 8 + al;
     dx := dh shl 8 + dl;
     intr($14,mypak);
     end;
end;

procedure send_line;
{Break the number apart and TALK to the modem}
begin
    NUMBER:=CONCAT(prefix,DIALIt,chr(13));
    len:=length(number);
    ct:=1;
      while ct<=len do
          begin
          digit:=copy(number,ct,1);
          al:=ord(digit);
          ah:=1;
          dl:=0;
          talk;
          ct:=ct+1;
       end;
end;

procedure setup;
{set communications parameters}
begin
     ah:=0;
     dl:=0;
     al:=131;
     talk;
     ah:=4;
     dl:=0;
     talk;
end;

procedure hangup;
{What else, but hang up the modem}
begin
    writeln('Hit any key to hang up modem');
    read(dummy);
    dialit:='h0';
    send_line;
end;


PROCEDURE MAIN;
{Get the number to dial or special commands}
begin
     setup;
           writeln('');
           write('Number to Dial ( . = quit  [enter] = last number): ');
           readln(dialit);
              if dialit='' then
              begin
              dialit:=last;
              end;
           LAST:=DIALIT;
     if last<>'.' then
     begin
write ('Dialing ');
writeln(dialit);
     send_line;
     hangup;
     end;
end;

BEGIN
{Get and store the prefix code and get down to business}
writeln('Enter personal dialing code  (MCI access etc) or [enter] for none');
writeln('This code remains active for the complete dialing session');
readln(personal);
prefix:=concat('ATDT',personal);
clrscr;
     WHILE LAST<>'.' do
     begin
     main;
     end;
last:='ddd';
end.
:= buf_start +1;
  check_range(buf_start);
  inline ($FB);  {very important}
  r