home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxftpsrc.zip / ALIASDE.VRX next >
Text File  |  1995-10-05  |  6KB  |  230 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         AliasDEWindow_Close
  67. */
  68. AliasDEWindow_Close:
  69.     /* call Quit */
  70. return
  71.  
  72. /*:VRX         AliasDEWindow_Create
  73. */
  74. AliasDEWindow_Create:
  75.     if ( word( InitArgs.1, 1) = 'EDIT' ) then do
  76.         rc = VRSet( "EF_AliasName",   "Value", InitArgs.2 )
  77.         rc = VRSet( "EF_AliasHost",   "Value", InitArgs.3 )
  78.         rc = VRSet( "EF_AliasLogin",  "Value", InitArgs.4 )
  79.         rc = VRSet( "EF_AliasPasswd", "Value", InitArgs.5 )
  80.         rc = VRSet( "EF_AliasCWD",    "Value", InitArgs.6 )
  81.         rc = VRSet( "DDCB_HostOS",    "Value", InitArgs.7 )
  82.  
  83.         if ( translate( InitArgs.4 ) = "ANONYMOUS" ) | ,
  84.            ( translate( InitArgs.4 ) = "FTP" ) then
  85.             rc = VRSet( "CB_AnonFtp", "Set", 1 )            
  86.     end 
  87. return
  88.  
  89. /*:VRX         BasicErrMsg
  90. */
  91. BasicErrMsg: 
  92.     /* Easy way of showing simple error messages, thanks to VX-REXX's
  93.      * ability to expand the dialog box to fit the message.
  94.      */
  95.     ErrMessage = arg(1)
  96.  
  97.     OK = 1
  98.     Buttons.OK = "OK"
  99.     Cancel = 2
  100.     Buttons.Cancel = "Cancel"
  101.     Buttons.0 = 2
  102.     
  103.     id = VRMessage( VRWindow(), ErrMessage, "Error", ,
  104.                      "Error", "Buttons.", OK, Cancel )
  105.     drop ErrMessage
  106.  
  107. return
  108.  
  109. /*:VRX         BuildHostOSList
  110. */
  111. BuildHostOSList:
  112.     HostOS.1 = "auto detect"
  113.     HostOS.2 = "OS/2"
  114.     HostOS.3 = "UNIX"
  115.     HostOS.4 = "NetWare"
  116.     HostOS.5 = "Windows NT"
  117.     HostOS.6 = "IBM VM"
  118.     HostOS.7 = "VAX VMS"
  119.     HostOS.8 = "Macintosh"
  120.     HostOS.0 = 8
  121.     rc = VRMethod( "DDCB_HostOS", "AddStringList", "HostOS.",  )
  122.     if ( word( InitArgs.1, 1) = 'NEW' ) then
  123.         rc = VRSet( "DDCB_HostOS", "Value", "auto detect" )
  124.  
  125.  
  126. return
  127.  
  128. /*:VRX         CB_AnonFtp_Click
  129. */
  130. CB_AnonFtp_Click:
  131.     AnonFTP = VRGet( "CB_AnonFtp", "Set" )
  132.     if ( AnonFTP = 1 ) then do
  133.         rc = VRSet( "EF_AliasLogin", "Value", "anonymous" )
  134.         rc = VRMethod( "Application", "GetVar", "IniFile" )
  135.         AnonPasswd = VRGetIni( "VxFTP", "Email", IniFile )
  136.  
  137.         if ( rc = 1 ) then
  138.             rc = VRSet( "EF_AliasPasswd", "Value", AnonPasswd )
  139.         else
  140.             rc = VRSet( "EF_AliasPasswd", "Value", "os2user@here.org" )
  141.     end
  142.     else do
  143.         rc = VRSet( "EF_AliasLogin",  "Value", "" )
  144.         rc = VRSet( "EF_AliasPasswd", "Value", "" )
  145.     end /* else */
  146. return
  147.  
  148. /*:VRX         Fini
  149. */
  150. Fini:
  151.     window = VRWindow()
  152.     call VRSet window, "Visible", 0
  153.     drop window
  154.  
  155. return retCode
  156.  
  157. /*:VRX         Halt
  158. */
  159. Halt:
  160.     signal _VREHalt
  161. return
  162.  
  163. /*:VRX         Init
  164. */
  165. Init:
  166.     call BuildHostOSList
  167.  
  168.     window = VRWindow()
  169.     call VRMethod window, "CenterWindow"
  170.     call VRSet window, "Visible", 1
  171.     call VRMethod window, "Activate"
  172.     drop window
  173.  
  174.     retCode = ""
  175. return
  176.  
  177. /*:VRX         PB_Cancel_Click
  178. */
  179. PB_Cancel_Click:
  180.     call Quit
  181. return
  182.  
  183. /*:VRX         PB_OK_Click
  184. */
  185. PB_OK_Click:
  186.  
  187.     alias = VRGet( "EF_AliasName", "Value" )
  188.     if ( alias = "" ) then do
  189.         call BasicErrMsg "Alias must have a name"
  190.         return
  191.     end
  192.  
  193.     host = VRGet("EF_AliasHost", "Value")
  194.     if ( host = "" ) then do
  195.         call BasicErrMsg "Alias must have a host"
  196.         return
  197.     end
  198.  
  199.     hostOS = VRGet( "DDCB_HostOS", "Value" )
  200.     login = VRGet("EF_AliasLogin", "Value")
  201.     if ( login = "" ) then do
  202.         call BasicErrMsg "Alias must have a Login name"
  203.         return
  204.     end
  205.  
  206.     passwd = VRGet("EF_AliasPasswd", "Value")
  207.     cwd = VRGet("EF_AliasCWD", "Value")
  208.  
  209.     /* Strip away leading or trailing blanks        */
  210.     alias  = strip(alias)
  211.     host   = strip(host)
  212.     login  = strip(login)
  213.     passwd = strip(passwd)
  214.     cwd    = strip(cwd)
  215.  
  216.  
  217.     retCode = alias || "|" || host || "|" || login || "|" || passwd || "|" || cwd || "|" || hostOS
  218.     call Quit
  219.  
  220. return
  221.  
  222. /*:VRX         Quit
  223. */
  224. Quit:
  225.     window = VRWindow()
  226.     call VRSet window, "Shutdown", 1
  227.     drop window
  228. return
  229.  
  230.