home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxftpsrc.zip / XferProg.VRX < prev   
Text File  |  1995-10-05  |  2KB  |  60 lines

  1. /*:VRX         Main
  2. */
  3. Main:
  4.     signal on halt
  5.  
  6.     parse arg SysType getFile getFileSize remoteFile
  7.  
  8.     if ( remoteFile = "" ) then do
  9.         BaseText = 'call VRSet "MainWindow", "StatusText", "Getting ""' || getFile || '""'
  10.         TextToSend = BaseText || '"'
  11.         rc = VRMethod( "Application", "PostQueue", 0, 1, TextToSend )
  12.      end
  13.     else do
  14.         BaseText = 'call VRSet "MainWindow", "StatusText", "Getting ""' || remoteFile || '"" as ""' || getFile'""'
  15.         TextToSend = BaseText || '"'
  16.         rc = VRMethod( "Application", "PostQueue", 0, 1, TextToSend )
  17.     end
  18.  
  19.     /* Try for 20 seconds for the Remote thread to start the download.
  20.      * So 20 seconds is the timeout. If a stream isn't established by then,
  21.      * assume that some error occurred.
  22.      */
  23.     do i = 1 to 20
  24.         if ( stream( getFile, 'c', 'query exist' ) = "" ) then
  25.             call SysSleep 1
  26.         else
  27.             leave
  28.     end
  29.  
  30.     if ( i < 20 ) then do
  31.         NewSize = 0
  32.         if ( SysType = 'VMS' ) | (SysType = 'VM' ) then 
  33.             /* For VMS and VM systems, we don't get file size info in Bytes, just blocks */
  34.             do forever
  35.                 NewSize = stream( getFile, 'c', 'query size' )
  36.                 rc = VRMethod( "Application", "PostQueue", 0, 1, BaseText  NewSize'"')
  37.                 call SysSleep 1
  38.             end /* do */
  39.  
  40.         else
  41.             do forever
  42.                 NewSize = stream( getFile, 'c', 'query size' )
  43.                 Percentage = NewSize / getFileSize * 100
  44.                 Percentage = format( Percentage, 3, 0 )
  45.                 if ( Percentage < 100 ) then do
  46.                     TextToSend = BaseText  NewSize'/'getFileSize  '['Percentage '%]"'
  47.                     rc = VRMethod( "Application", "PostQueue", 0, 1, TextToSend )
  48.                 end
  49.                 call SysSleep 1
  50.             end /* do */
  51.  
  52. exit
  53.  
  54. /*:VRX         Halt
  55. */
  56. Halt:
  57.  
  58. exit
  59.  
  60.