home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / GETDOWNL.MOD < prev    next >
Text File  |  1988-02-15  |  5KB  |  143 lines

  1. (*----------------------------------------------------------------------*)
  2. (*        Get_Download_Protocol --- Get File Transfer Protocol          *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Get_Download_Protocol : Transfer_Type ;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Function:   Get_Download_Protocol                                *)
  10. (*                                                                      *)
  11. (*     Purpose:    Gets file name and transfer protocol for download.   *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Transtyp := Get_Download_Protocol: Transfer_Type;             *)
  16. (*                                                                      *)
  17. (*----------------------------------------------------------------------*)
  18.  
  19. VAR
  20.    Transfer_Kind : Transfer_Type;
  21.    I             : INTEGER;
  22.    OK_File_Name  : BOOLEAN;
  23.    AFile         : FILE;
  24.    Quit          : BOOLEAN;
  25.  
  26. BEGIN (* Get_Download_Protocol *)
  27.                                    (* Copy keyboard data before we screw *)
  28.                                    (* it up so we can get file name      *)
  29.  
  30.    Saved_Kbd_File_Name := Keyboard_Line;
  31.  
  32.    IF Auto_Find_FileNames THEN
  33.       Get_Auto_File_Name( Saved_Kbd_File_Name , FileName )
  34.    ELSE
  35.       FileName := '';
  36.  
  37.                                    (* Display menu of transfer types *)
  38.                                    (* and get transfer kind.         *)
  39.  
  40.    Display_Transfer_Types( 'Choose protocol: ',
  41.                            Default_Transfer_Type,
  42.                            FALSE,
  43.                            3, 10, 50, 21, 11,
  44.                            FALSE,
  45.                            Transfer_Kind );
  46.  
  47.                                    (* Get file name to use if not *)
  48.                                    (* batch transfer              *)
  49.    Ok_File_Name := FALSE;
  50.    Quit         := ( Transfer_Kind = None );
  51.  
  52.    IF Quit THEN
  53.       BEGIN
  54.          Restore_Screen_And_Colors( Saved_Screen );
  55.          Get_Download_Protocol := Transfer_Kind;
  56.          EXIT;
  57.       END;
  58.  
  59.    IF Single_File_Protocol[Transfer_Kind] THEN
  60.       BEGIN
  61.  
  62.          REPEAT
  63.  
  64.             FOR I := 18 TO 21 DO
  65.                BEGIN
  66.                   GoToXY( 1 , I );
  67.                   ClrEol;
  68.                END;
  69.  
  70.             GoToXY( 2 , 18 );
  71.             WRITE('Enter Filename.Ext: ');
  72.  
  73.             GoToXY( 2 , 19 );
  74.             WRITE('>');
  75.             Read_Edited_String(FileName);
  76.             WRITELN;
  77.  
  78.             IF ( ( LENGTH( FileName ) = 0 ) OR ( FileName = CHR( ESC ) ) ) THEN
  79.                BEGIN
  80.                   Quit          := TRUE;
  81.                   Transfer_Kind := None;
  82.                END
  83.             ELSE
  84.                BEGIN
  85.  
  86.                   Add_Path( FileName, Download_Dir_Path, Saved_Kbd_File_Name );
  87.  
  88.                   ASSIGN(AFile,Saved_Kbd_File_Name);
  89.                      (*!I- *)
  90.                   RESET( AFile );
  91.                      (*!I+ *)
  92.  
  93.                   IF ( Int24Result <> 0 ) THEN
  94.                      OK_File_Name := TRUE
  95.                   ELSE
  96.                      BEGIN
  97.                         OK_File_Name := YesNo( Saved_Kbd_File_Name + ' exists, overwrite (Y/N) ? ');
  98.                            (*!I-*)
  99.                         CLOSE( AFile );
  100.                            (*!I+*)
  101.                         I := Int24Result;
  102.                      END;
  103.  
  104.                END;
  105.  
  106.          UNTIL( OK_File_Name OR Quit );
  107.  
  108.          IF ( NOT Quit ) THEN
  109.             BEGIN
  110.  
  111.                ASSIGN( AFile, Saved_Kbd_File_Name );
  112.                      (*!I- *)
  113.                REWRITE( AFile );
  114.                      (*!I+ *)
  115.  
  116.                IF ( Int24Result <> 0 ) THEN
  117.                   BEGIN
  118.                      Transfer_Kind := None;
  119.                      WRITE('*** Can''t open file, receive cancelled ***');
  120.                      Window_Delay;
  121.                   END;
  122.  
  123.                   (*!I-*)
  124.                CLOSE( AFile );
  125.                   (*!I+*)
  126.  
  127.                I := INT24Result;
  128.  
  129.             END;
  130.  
  131.       END  (* Get file name *);
  132.                                    (* Remove this window            *)
  133.  
  134.    Restore_Screen_And_Colors( Saved_Screen );
  135.  
  136.    Use_Time_Sent := Use_Block_Zero;
  137.  
  138.                                    (* Return transfer protocol type *)
  139.  
  140.    Get_Download_Protocol := Transfer_Kind;
  141.  
  142. END   (* Get_Download_Protocol *);
  143.