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

  1. /*:VRX         Main
  2. */
  3. /*  Main
  4. */
  5. Main:
  6. /*  Process the arguments.
  7.     Get the parent window.
  8. */
  9.     parse source . calledAs .
  10.     parent = ""
  11.     argCount = arg()
  12.     argOff = 0
  13.     if( calledAs \= "COMMAND" )then do
  14.         if argCount >= 1 then do
  15.             parent = arg(1)
  16.             argCount = argCount - 1
  17.             argOff = 1
  18.         end
  19.     end
  20.     InitArgs.0 = argCount
  21.     if( argCount > 0 )then do i = 1 to argCount
  22.         InitArgs.i = arg( i + argOff )
  23.     end
  24.     drop calledAs argCount argOff
  25.  
  26. /*  Load the windows
  27. */
  28.     call VRInit
  29.     parse source . . spec
  30.     _VREPrimaryWindowPath = ,
  31.         VRParseFileName( spec, "dpn" ) || ".VRW"
  32.     _VREPrimaryWindow = ,
  33.         VRLoad( parent, _VREPrimaryWindowPath )
  34.     drop parent spec
  35.     if( _VREPrimaryWindow == "" )then do
  36.         call VRMessage "", "Cannot load window:" VRError(), ,
  37.             "Error!"
  38.         _VREReturnValue = 32000
  39.         signal _VRELeaveMain
  40.     end
  41.  
  42. /*  Process events
  43. */
  44.     call Init
  45.     signal on halt
  46.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  47.         _VREEvent = VREvent()
  48.         interpret _VREEvent
  49.     end
  50. _VREHalt:
  51.     _VREReturnValue = Fini()
  52.     call VRDestroy _VREPrimaryWindow
  53. _VRELeaveMain:
  54.     call VRFini
  55. exit _VREReturnValue
  56.  
  57. VRLoadSecondary: procedure
  58.     name = arg( 1 )
  59.  
  60.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  61.     call VRMethod window, "CenterWindow"
  62.     call VRSet window, "Visible", 1
  63.     call VRMethod window, "Activate"
  64. return window
  65.  
  66. /*:VRX         BasicErrMsg
  67. */
  68. BasicErrMsg:
  69.     parse arg ErrMessage
  70.  
  71.     OK = 1
  72.     Buttons.OK = "OK"
  73.     Cancel = 2
  74.     Buttons.Cancel = "Cancel"
  75.     Buttons.0 = 2
  76.     
  77.     id = VRMessage( VRWindow(), ErrMessage, "Error", ,
  78.                      "Error", "Buttons.", OK, Cancel )
  79.     drop ErrMessage
  80.  
  81. return
  82.  
  83. /*:VRX         Fini
  84. */
  85. Fini:
  86.     window = VRWindow()
  87.     call VRSet window, "Visible", 0
  88.     drop window
  89. return 0
  90.  
  91. /*:VRX         Halt
  92. */
  93. Halt:
  94.     signal _VREHalt
  95. return
  96.  
  97. /*:VRX         Init
  98. */
  99. Init:
  100.     window = VRWindow()
  101.     call VRMethod window, "CenterWindow"
  102.     call VRSet window, "Visible", 1
  103.  
  104.     parse value InitArgs.1 with LocalFile "||" DownloadFileName "||" Locale
  105.  
  106.     if ( Locale = "VIEWER" ) then
  107.         call ShowText
  108.     else
  109.         call ShowFile
  110.  
  111.     call VRMethod window, "Activate"
  112.     drop window
  113. return
  114.  
  115. /*:VRX         Quit
  116. */
  117. Quit:
  118.     window = VRWindow()
  119.     call VRSet window, "Shutdown", 1
  120.     drop window
  121. return
  122.  
  123. /*:VRX         ShowFile
  124. */
  125. ShowFile:
  126.     /* Get the file as the first Param of passed data and read into
  127.      * what will become a very long string, TextFile. Set the
  128.      * value of MLE_TextFile to the long string TextFile.
  129.      */
  130.     CR_LF = "0d0a"x
  131.     TextFile = ""
  132.     rc = VRSet( "Window1", "Caption", DownloadFileName )
  133.  
  134.     do while lines( LocalFile )
  135.         TextFile = TextFile || linein( LocalFile ) || CR_LF
  136.     end
  137.     rc = lineout( LocalFile )
  138.  
  139.     rc = VRSet( "MLE_TextFile", "Value", TextFile )
  140.  
  141.     if ( Locale  = "REMOTE" ) then do
  142.         rc = VRDeleteFile( LocalFile )
  143.         if (rc = 0) then
  144.             call BasicErrMsg "Couldn't delete" DownloadFileName "on local system."
  145.     end
  146.  
  147. return
  148.  
  149. /*:VRX         ShowText
  150. */
  151. ShowText:
  152.     call VRMethod "Application", "GetVar", "remote_list."
  153.     
  154.     CR_LF = "0d0a"x
  155.     ViewFile = ""
  156.  
  157.     if ( Datatype( remote_list.0, "N" ) ) then do
  158.     
  159.         do i = 1 to remote_list.0
  160.             ViewFile = ViewFile || remote_list.i || CR_LF
  161.         end
  162.  
  163.         rc = VRSet( "Window1", "Caption", DownloadFileName )
  164.         rc = VRSet( "MLE_TextFile", "Value", ViewFile )
  165.     end
  166.     else
  167.         call BasicErrMsg "Listing not downloaded yet"
  168.  
  169. return
  170.  
  171. /*:VRX         Window1_Close
  172. */
  173. Window1_Close:
  174.     call Quit
  175. return
  176.  
  177. /*:VRX         Window1_Resize
  178. */
  179. Window1_Resize:
  180.     window = VRWindow()
  181.     width = VRGet( window, "InteriorWidth" )
  182.     height = VRGet( window, "InteriorHeight" )
  183.  
  184.     rc = VRSet( "MLE_TextFile", "Height", height )
  185.     rc = VRSet( "MLE_TextFile", "Width", width )
  186.  
  187.     drop window height width
  188. return
  189.  
  190.