home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / ddewsql.zip / DDEAPP3.VRX < prev    next >
Text File  |  1995-07-31  |  4KB  |  166 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; else do
  20.         call VROptions 'ImplicitNames'
  21.     end
  22.     InitArgs.0 = argCount
  23.     if( argCount > 0 )then do i = 1 to argCount
  24.         InitArgs.i = arg( i + argOff )
  25.     end
  26.     drop calledAs argCount argOff
  27.  
  28. /*  Load the windows
  29. */
  30.     call VRInit
  31.     parse source . . spec
  32.     _VREPrimaryWindowPath = ,
  33.         VRParseFileName( spec, "dpn" ) || ".VRW"
  34.     _VREPrimaryWindow = ,
  35.         VRLoad( parent, _VREPrimaryWindowPath )
  36.     drop parent spec
  37.     if( _VREPrimaryWindow == "" )then do
  38.         call VRMessage "", "Cannot load window:" VRError(), ,
  39.             "Error!"
  40.         _VREReturnValue = 32000
  41.         signal _VRELeaveMain
  42.     end
  43.  
  44. /*  Process events
  45. */
  46.     call Init
  47.     signal on halt
  48.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  49.         _VREEvent = VREvent()
  50.         interpret _VREEvent
  51.     end
  52. _VREHalt:
  53.     _VREReturnValue = Fini()
  54.     call VRDestroy _VREPrimaryWindow
  55. _VRELeaveMain:
  56.     call VRFini
  57. exit _VREReturnValue
  58.  
  59. VRLoadSecondary:
  60.     __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
  61.     if __vrlsWait then do
  62.         call VRFlush
  63.     end
  64.     __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
  65.     if __vrlsHWnd = '' then signal __vrlsDone
  66.     if __vrlsWait \= 1 then signal __vrlsDone
  67.     call VRSet __vrlsHWnd, 'WindowMode', 'Modal' 
  68.     __vrlsTmp = __vrlsWindows.0
  69.     if( DataType(__vrlsTmp) \= 'NUM' ) then do
  70.         __vrlsTmp = 1
  71.     end
  72.     else do
  73.         __vrlsTmp = __vrlsTmp + 1
  74.     end
  75.     __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
  76.     __vrlsWindows.0 = __vrlsTmp
  77.     do while( VRIsValidObject( VRWindow() ) = 1 )
  78.         __vrlsEvent = VREvent()
  79.         interpret __vrlsEvent
  80.     end
  81.     __vrlsTmp = __vrlsWindows.0
  82.     __vrlsWindows.0 = __vrlsTmp - 1
  83.     call VRWindow __vrlsWindows.__vrlsTmp 
  84.     __vrlsHWnd = ''
  85. __vrlsDone:
  86. return __vrlsHWnd
  87.  
  88. /*:VRX         DDEAPP3_Close
  89. */
  90. DDEAPP3_Close:
  91.  
  92.      /* get the values from the entry fields */
  93.      database = VRGet( "EF_1", "Value")
  94.      userid = VRGet( "EF_2", "Value" )
  95.      password = VRGet( "EF_3", "Value" )
  96.  
  97.      /* No information entered setting a default */     
  98.      if (database="" & userid="" & password="") then do
  99.         ok = VRSet( "DDEAPP3", "StatusText", "Setting the default" )
  100.         ok = VRSet("EF_1","Value","c:\wsql40\sample.db")
  101.         ok = VRSet("EF_2","Value","dba")
  102.         ok = VRSet("EF_3","Value","sql")
  103.         call VRSet VRWindow(), 'Pointer', 'Wait'
  104.         do i= 1 to 100000
  105.         end
  106.         call VRSet VRWindow(), 'Pointer', '<Default>'
  107.      end
  108.                   
  109.      /* store the information used by another file */
  110.      database = VRGet( "EF_1", "Value")
  111.      userid = VRGet( "EF_2", "Value" )
  112.      password = VRGet( "EF_3", "Value" )
  113.  
  114.      ok = VRMethod( "Application", "PutVar", "database", "database" )
  115.      ok = VRMethod( "Application", "PutVar", "userid", "userid" )
  116.      ok = VRMethod( "Application", "PutVar", "password", "password" )
  117.      
  118.      call Quit
  119. return
  120.  
  121. /*:VRX         Fini
  122. */
  123. Fini:
  124.     window = VRWindow()
  125.     call VRSet window, "Visible", 0
  126.     drop window
  127. return 0
  128.  
  129. /*:VRX         Halt
  130. */
  131. Halt:
  132.     signal _VREHalt
  133. return
  134.  
  135. /*:VRX         Init
  136. */
  137. Init:
  138.     window = VRWindow()
  139.     call VRMethod window, "Activate"
  140.     drop window
  141.     database =""
  142.     userid = ""
  143.     password = ""
  144.     call VRSet "DDEAPP3", "Visible", 0
  145.     Buttons.1 = "Ok"
  146.     Buttons.0 = 1
  147.     call VRMessage VRWindow(), "The topic name identifies the user, and optionally, the database to be used", "FYI", "None", "Buttons."
  148.     call VRSet "DDEAPP3", "Visible", 1
  149.     call VRSet "DDEAPP3", "StatusText", "If empty fields are left empty then a default sample will be chosen." 
  150. return
  151.  
  152. /*:VRX         PB_1_Click
  153. */
  154. PB_1_Click: 
  155.     call DDEAPP3_Close
  156. return
  157.  
  158. /*:VRX         Quit
  159. */
  160. Quit:
  161.     window = VRWindow()
  162.     call VRSet window, "Shutdown", 1
  163.     drop window
  164. return
  165.  
  166.