home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s4.arc / SENDMODE.MOD < prev    next >
Text File  |  1988-02-19  |  5KB  |  119 lines

  1. (*----------------------------------------------------------------------*)
  2. (*             Send_Modem_Command --- Send command to modem             *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Send_Modem_Command( Modem_Text : AnyStr );
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Send_Modem_Command                                   *)
  10. (*                                                                      *)
  11. (*     Purpose:    Sends command to modem                               *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*         Send_Modem_Command( Modem_Text : AnyStr );                   *)
  16. (*                                                                      *)
  17. (*           Modem_Text --- text of command to send to modem            *)
  18. (*                                                                      *)
  19. (*     Calls:                                                           *)
  20. (*                                                                      *)
  21. (*        Async_Send_Now                                                *)
  22. (*        Async_Receive                                                 *)
  23. (*                                                                      *)
  24. (*     Remarks:                                                         *)
  25. (*                                                                      *)
  26. (*          If the string to be sent has not "Wait For" markers, then   *)
  27. (*          it is sent in its entirety in one call here.  If there ARE  *)
  28. (*          "Wait For" characters, then the flag WaitString_Mode is set *)
  29. (*          TRUE, Script_When_Text is set to the character to be found, *)
  30. (*          and  Script_When_Reply_Text is set to the remainder of the  *)
  31. (*          function key string.  This allows the terminal emulation to *)
  32. (*          properly process any received characters while PibTerm is   *)
  33. (*          waiting for the selected string to appear.                  *)
  34. (*                                                                      *)
  35. (*----------------------------------------------------------------------*)
  36.  
  37.  
  38. VAR
  39.    I:       INTEGER;
  40.    L:       INTEGER;
  41.    Ch:      CHAR;
  42.    MO_Char: CHAR;
  43.    Done:    BOOLEAN;
  44.  
  45. BEGIN (* Send_Modem_Command *)
  46.  
  47.    L      := LENGTH( Modem_Text );
  48.    I      := 1;
  49.    Done   := FALSE;
  50.  
  51.    WHILE( I <= L ) AND ( NOT Done ) DO
  52.       BEGIN
  53.  
  54.          MO_Char := Modem_Text[I];
  55.  
  56.          IF MO_Char = FK_CR THEN
  57.             Async_Send_Now( CHR( CR ) )
  58.  
  59.          ELSE IF MO_Char = FK_Delay THEN
  60.             DELAY( One_Second_Delay )
  61.  
  62.          ELSE IF MO_Char = FK_Wait_For THEN
  63.             BEGIN   (* Wait For *)
  64.  
  65.                INC( I );
  66.  
  67.                IF ( I <= L ) THEN
  68.                   BEGIN
  69.  
  70.                      WITH Script_Wait_List[1] DO
  71.                         BEGIN
  72.                            NEW( Wait_Text );
  73.                            IF ( Wait_Text <> NIL ) THEN
  74.                               Wait_Text^ := Modem_Text[I];
  75.                            NEW( Wait_Reply );
  76.                            INC( I );
  77.                            IF ( Wait_Reply <> NIL ) THEN
  78.                               BEGIN
  79.                                  IF ( I <= L ) THEN
  80.                                     Wait_Reply^ := COPY( Modem_Text, I, SUCC( L - I ) )
  81.                                  ELSE
  82.                                     Wait_Reply^ := '';
  83.                                  Script_Wait_Check_Length := 1;
  84.                               END;
  85.                         END;
  86.  
  87.                      Script_Wait_Count      := 1;
  88.                      WaitString_Mode        := TRUE;
  89.                      Really_Wait_String     := TRUE;
  90.                      Script_Wait_Time       := Script_Default_Wait_Time;
  91.                      IF ( Script_Wait_Time <= 0 ) THEN
  92.                         Script_Wait_Time := 60;
  93.                      Script_Wait_Failure    := 0;
  94.                      Done                   := TRUE;
  95.                      Script_Wait_Start      := TimeOfDay;
  96.  
  97.                   END;
  98.  
  99.             END
  100.          ELSE IF MO_Char = FK_Ctrl_Mark THEN
  101.             BEGIN
  102.                IF ( ( I + 2 ) <= L ) THEN
  103.                   IF ( Modem_Text[ SUCC( I ) ] = '''' ) THEN
  104.                      INC( I , 2 );
  105.                Async_Send_Now( Modem_Text[I] );
  106.             END
  107.          ELSE
  108.             BEGIN
  109.                Async_Send_Now( Modem_Text[I] );
  110.                IF ( Modem_Command_Delay > 0 )
  111.                   THEN DELAY( Modem_Command_Delay );
  112.             END;
  113.  
  114.          INC( I );
  115.  
  116.       END;
  117.  
  118. END   (* Send_Modem_Command *);
  119.