home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
misc2
/
dialv23.lzh
/
HAYES.INC
< prev
next >
Wrap
Text File
|
1985-08-03
|
4KB
|
140 lines
{********* This file is an "include" file to be used with DIAL.PAS. *********}
Function GetHayesRsp( secs : Integer ) : Integer;
{
Use this function to get the modem's response for any given command. Response
is returned as an integer value 0 through 5. Call with the maximum number of
seconds you wish to wait.
}
Var
intchr : char;
rspcod : integer;
rspstr : string[15];
goodrsp : array[1..6] of string[15];
j : integer;
result : boolean;
Begin
goodrsp[1] := 'OK';
goodrsp[2] := 'CONNECT';
goodrsp[3] := 'RING';
goodrsp[4] := 'NO CARRIER';
goodrsp[5] := 'ERROR';
goodrsp[6] := 'CONNECT 1200';
MsgLine('Waiting for modem response ...',FNormal);
rspcod := -1; {-1 means timeout}
Repeat
Begin
GotoXY(70,24);
Write(secs:2);
result := ReadCommChar; {Get a char from the port}
If CommIn.Char <> chr(0) Then
Begin
If CommIn.Char in ['0'..'5'] Then {Numeric response}
Begin
rspcod := ord(commin.char) - ord('0');
GetCommChar; {Get the carriage return}
secs := 0; {Say done}
End
Else If CommIn.Char = chr(13) Then {Word response}
Begin
GetCommChar; {Get the linefeed}
rspstr := ''; {Init the response buffer}
GetCommChar; {Get first char of response}
While commin.char in [' ','0'..'2','A'..'Z'] Do
Begin
rspstr := rspstr + commin.char;
GetCommChar;
End;
GetCommChar; {Get the linefeed}
For j := 1 to 6 Do
Begin
If rspstr = goodrsp[j] Then
Begin
rspcod := j-1;
secs := 0;
End;
End;
End;
End;
If secs > 0 Then {Don't wait if already done}
Begin
Delay(1000);
secs := secs-1;
If KeyPressed Then {User wants to abort call}
Begin
Read(KBD,intchr);
result := WriteCommChar(chr(13));
End;
End;
End;
Until secs <= 0;
GetHayesRsp := rspcod;
End; {Function GetHayesRsp}
Function InitHayes : Boolean;
{
Initialize the Hayes SmartModem. Return false if this failed so top level can
abort.
}
Var
Init_String : Stringlong;
J : Integer;
result : boolean;
Begin
MsgLine('Initializing the modem ...',FNormal);
result := DisconnectModem;
result := InitPort;
init_string := 'ATE0F1H0M1Q0TV1X1S7=45' + chr(13);
For j := 1 to length(init_string) Do
Begin
result := WriteCommChar(init_string[j]);
Delay(hayes_delay);
End;
j := GetHayesRsp(10);
WrtModemRsp(j);
If j = 0 Then Inithayes := True Else InitHayes := False;
End; {Function INITHAYES}
Procedure DialHayes;
{
Dial the Hayes with the user selected string.
}
Const
validchar : Set of Char = [',','0'..'9'];
Var
ndx : integer;
thenum : String[15];
onenum : Str133;
numlen : integer;
result : Boolean;
pnc : char;
Begin
MsgLine('Dialing the phone ...',FNormal);
Numlen := length(dir_entry[cur_dir_ent].num);
thenum := dir_entry[cur_dir_ent].num;
Result := WriteCommChar('A'); Delay(hayes_delay);
Result := WriteCommChar('T'); Delay(hayes_delay);
Result := WriteCommChar('D'); Delay(hayes_delay);
Result := WriteCommChar('T'); Delay(hayes_delay);
ndx := 1;
Repeat
Begin
If (thenum[ndx] in validchar) THEN
Begin
onenum := thenum[ndx];
pnc := thenum[ndx];
FastVideo(onenum,FBoldReverse,Char_Attrib,1,cur_dir_ent-top_dir_ent+fsl, ndx+4);
result := WriteCommChar(pnc);
delay(hayes_delay);
End;
ndx := ndx+1;
numlen := numlen - 1;
End;
Until numlen = 0;
Result := WriteCommChar(Chr(13));
End; {procedure DialHayes}