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

  1. (*----------------------------------------------------------------------*)
  2. (*  Transfer_Through_Batch_File --- Transfer file using batch file      *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Transfer_Through_Batch_File( Transfer_Protocol : Transfer_Type;
  6.                                        TName             : String12;
  7.                                        Direc             : CHAR );
  8.  
  9. (*----------------------------------------------------------------------*)
  10. (*                                                                      *)
  11. (*     Procedure:  Transfer_Through_Batch_File                          *)
  12. (*                                                                      *)
  13. (*     Purpose:    Sends or receives file using transfer protocol       *)
  14. (*                 defined in batch file.                               *)
  15. (*                                                                      *)
  16. (*     Calling Sequence:                                                *)
  17. (*                                                                      *)
  18. (*        Transfer_Through_Batch_File( Transfer_Protocol: Transfer_Type;*)
  19. (*                                     TName            : String12;     *)
  20. (*                                     Direc            : CHAR );       *)
  21. (*                                                                      *)
  22. (*           Transfer_Protocol --- Transfer protocol used               *)
  23. (*           TName --- The name of the batch file to be used.           *)
  24. (*           Direc --- 'S' if sending file, 'R' if receiving file.      *)
  25. (*                                                                      *)
  26. (*     Remarks:                                                         *)
  27. (*                                                                      *)
  28. (*        Parameters passed to batch file:                              *)
  29. (*                                                                      *)
  30. (*           %1 = comm port number                                      *)
  31. (*           %2 = baud rate                                             *)
  32. (*           %3 = parity                                                *)
  33. (*           %4 = data bits                                             *)
  34. (*           %5 = directory to send files from/receive files to         *)
  35. (*           %6 = file spec of files to send/receive                    *)
  36. (*                                                                      *)
  37. (*----------------------------------------------------------------------*)
  38.  
  39. VAR
  40.    S_Baud_Rate   : STRING[6];
  41.    S_Port        : STRING[3];
  42.    S_BlockSize   : STRING[6];
  43.    S_Data_Bits   : STRING[2];
  44.    Cur_Path      : FileStr;
  45.    S_Trans_Dir   : FileStr;
  46.    L_Trans_Dir   : INTEGER;
  47.    Trans_Str     : AnyStr;
  48.    Save_Close    : BOOLEAN;
  49.    Err           : INTEGER;
  50.    Direction     : STRING[10];
  51.  
  52. BEGIN (* Transfer_Through_Batch_File *)
  53.  
  54.                                    (* Get comm port data *)
  55.  
  56.    STR( Baud_Rate:6 , S_Baud_Rate );
  57.    STR( Comm_Port:3 , S_Port      );
  58.    STR( Data_Bits:2 , S_Data_Bits );
  59.  
  60.                                    (* Remember current drive/directory *)
  61.    GetDir( 0 , Cur_Path );
  62.    Err := INT24Result;
  63.                                    (* Get transfer directory *)
  64.    IF ( Direc = 'S' ) THEN
  65.       BEGIN
  66.          IF Host_Mode THEN
  67.             S_Trans_Dir    := Host_Mode_Download
  68.          ELSE
  69.             S_Trans_Dir    := '';
  70.          Direction := ' send: ';
  71.       END
  72.    ELSE
  73.       BEGIN
  74.          IF Host_Mode THEN
  75.             S_Trans_Dir := Host_Mode_Upload
  76.          ELSE
  77.             S_Trans_Dir := Download_Dir_Path;
  78.          Direction := ' receive: ';
  79.       END;
  80.                                    (* If directory name is null, *)
  81.                                    (* make it current directory. *)
  82.    IF ( S_Trans_Dir = '' ) THEN
  83.       S_Trans_Dir := Cur_Path;
  84.                                    (* Remove trailing slash *)
  85.  
  86.    L_Trans_Dir := LENGTH( S_Trans_Dir );
  87.  
  88.    IF ( S_Trans_Dir[L_Trans_Dir] = '\' ) THEN
  89.       BEGIN
  90.          DELETE( S_Trans_Dir, L_Trans_Dir, 1 );
  91.          DEC   ( L_Trans_Dir );
  92.       END;
  93.                                    (* Build batch file invocation *)
  94.  
  95.    Trans_Str := TRIM( TName         +
  96.                       S_Port        +
  97.                       S_Baud_Rate   + ' ' +
  98.                       Parity        +
  99.                       S_Data_Bits   + ' ' +
  100.                       S_Trans_Dir   + ' ' +
  101.                       FileName );
  102.  
  103.    Save_Close         := Close_Comm_For_Dos;
  104.    Close_Comm_For_Dos := TRUE;
  105.  
  106.    Write_Log( LTrim( Transfer_Name_List[SUCC(ORD(Transfer_Protocol))] ) +
  107.               Direction + Trans_Str, FALSE, TRUE );
  108.  
  109.                                    (* Move to transfer directory *)
  110.  
  111.    IF ( L_Trans_Dir > 0 ) THEN
  112.       BEGIN
  113.          ChDir( S_Trans_Dir );
  114.          Err := INT24Result;
  115.       END;
  116.                                    (* Invoke batch file *)
  117.    DosJump( Trans_Str );
  118.  
  119.    Close_Comm_For_Dos := Save_Close;
  120.  
  121.                                    (* Restore current drive/directory *)
  122.    IF ( L_Trans_Dir > 0 ) THEN
  123.       BEGIN
  124.          ChDir( Cur_Path );
  125.          Err := INT24Result;
  126.       END;
  127.  
  128. END   (* Transfer_Through_Batch_File *);
  129.