home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / vselansp.zip / WINDOW1.VRX < prev    next >
Text File  |  1995-10-13  |  16KB  |  637 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         Common
  89. */
  90. Common: 
  91.  
  92. return
  93.  
  94. /*:VRX         Config_Close
  95. */
  96. Config_Close: 
  97.     call Config_Fini
  98. return
  99.  
  100. /*:VRX         Config_Create
  101. */
  102. Config_Create: 
  103.     call Config_Init
  104. return
  105.  
  106. /*:VRX         Config_Fini
  107. */
  108. Config_Fini: 
  109.     window = VRInfo( "Window" )
  110.     call VRDestroy window
  111.     drop window
  112. return
  113. /*:VRX         Config_Init
  114. */
  115. Config_Init: 
  116.     window = VRInfo( "Object" )
  117.     if( \VRIsChildOf( window, "Notebook" ) ) then do
  118.         call VRMethod window, "CenterWindow"
  119.         call VRSet window, "Visible", 1
  120.         call VRMethod window, "Activate"
  121.     end
  122.     drop window
  123. return
  124.  
  125. /*:VRX         Fini
  126. */
  127. Fini:
  128.     window = VRWindow()
  129.     call VRSet window, "Visible", 0
  130.     drop window
  131.  
  132. if xb <> "YES" then do
  133.  time = Time( "M")
  134.  date = Date( "D")
  135.  time = date||time 
  136.  time = time ||".log"
  137.  say time
  138.  say "copying to logfile  "||time
  139.  "copy C:\LANSPOOL\Current.log C:\LANSPOOL\LOGS\"||time
  140. Say "Deleteing queues"
  141.  Call RxQueue "Delete", "Getque"
  142.  Call RxQueue "Delete", "Gotque"
  143.  Call RxQueue "Delete", "taskque"
  144.  
  145.       ok = VRRedirectStdio("Off") 
  146.  
  147. return 0
  148.  
  149. /*:VRX         Halt
  150. */
  151. Halt:
  152.     signal _VREHalt
  153. return
  154.  
  155. /*:VRX         Init
  156. */
  157. Init:
  158.     window = VRWindow()
  159.     call VRMethod window, "CenterWindow"
  160.     call VRSet window, "Visible", 1
  161.     call VRMethod window, "Activate"
  162.     drop window
  163.  
  164.     ok = VRRedirectStdio("On","C:\LANSPOOL\Current.log") 
  165.     call VRSet "Console", "Left", "10", "Top", "10"
  166.     call VRSet "Console", "Width", "10", "Height", "10"
  167.    /* call VRSet "Console", "WindowListTitle", " "*/
  168.     call RxFuncAdd 'SysSleep' , 'RexxUtil', 'SysSleep'
  169.     datechk = Date("U")
  170.     time = Date( "W")
  171.     date = Date( "L")
  172.     date = time||" "||date 
  173.     time = Time( "N")
  174.     Say "Program Started at "||date||" "||time 
  175.     Say "Activity logging has begun"
  176.     Say "Checking for a configuration file..............."
  177.  
  178.     ok = VRFileExists( "C:\LANSPOOL\CONFIG\CONFIG.DAT" )
  179.        
  180.         IF ok = "1" then do
  181.         say "Configuration file found...will process entries"
  182.           end
  183.         else do
  184.         id = VRMessage( VRWindow(), "Please define a configuration file pairing a VSE/ESA LST queue to a LAN SERVER directory. Then restart this program!", "Missing configuration file", "Warning", , WILL DO!,  )
  185.         return
  186.         end
  187.  
  188.         Say "Creating queues"
  189.         Call RxQueue "Create", "Getque"
  190.         Call RxQueue "Create", "Gotque"
  191.         Call RxQueue "Create", "taskque"
  192.         Call REFRESH
  193.         
  194.         If Filecnt = 0 then do
  195.         SAY "THERE ARE NO FILES IN SELECTED LST QUEUE TO PROCESS"
  196.         time = Time( "C" )
  197.         SAY time||" ENDING PROGRAM NOW.........................."
  198.         call Quit
  199.         call Fini
  200.         end
  201.  
  202. /* SETUP FOR TIMER PROCESSING */
  203. waiting = "NO"
  204. timecount = 0
  205. ok = VRSet( "TM_1", "Enabled", 1 ) /* REENABLE TRIGGER */
  206. ok = VRSet( "TM_1", "Delay", 2000 )
  207.  
  208. Return
  209.  
  210.  
  211.  
  212. /*:VRX         IPB_2_Click
  213. */
  214. IPB_2_Click: 
  215. "copy C:\LANSPOOL\Current.log C:\LANSPOOL\temp.log"
  216. "E C:\LANSPOOL\temp.log"
  217. return
  218.  
  219. /*:VRX         IPB_3_Click
  220. */
  221. IPB_3_Click: 
  222.  
  223.  path = VRFileDialog(VRWindow(),"LOG TO VIEW?",,"C:\LANSPOOL\Logs\*")
  224.     if path = "" then return
  225.     time = time( "C")
  226.     say path||" LOG FILE viewed at "||time
  227.     EPM.EXE path
  228. return
  229.  
  230. return
  231.  
  232. /*:VRX         IPB_4_Click
  233. */
  234. IPB_4_Click: 
  235. window = VRLoadSecondary( "CONFIG" )
  236.  
  237. return
  238.  
  239. /*:VRX         PB_10_Click
  240. */
  241. PB_10_Click: 
  242.     ok = VRFileExists("C:\LANSPOOL\CONFIG\CONFIG.DAT" )
  243.     IF ok = "1" then do
  244.         NOP
  245.     end
  246.     else do
  247.         id = VRMessage( VRWindow(), "There is no Configuration File defined. Please add a definition, then restart this program!", "Missing configuration file", "Warning", , WILL DO!,  )
  248.         return
  249.     end 
  250.  
  251.     value = VRGet( "SPIN_1", "Value" )
  252.     class = "REMOVE VSE/ESA LST CLASS "||value||" ?"
  253.     Button.0 = 2
  254.     Button.1 = "CANCEL"
  255.     Button.2 = "CONTINUE"
  256.     Okay = VRMessage("Window1", class, "DELETE VSE/ESA LIST CLASS ENTRY?:", "Q", "Button.",1,1)
  257.     If Okay = 1 then return
  258.  
  259.  
  260.     infile = "C:\LANSPOOL\CONFIG\CONFIG.DAT"
  261.     LINEIN(infile,1,0)
  262.     outfile = "C:\LANSPOOL\CONFIG\CONFIG.DEL"
  263.  
  264.     Do until LINES(infile) = "0"
  265.         thisline = LINEIN(infile)
  266.         selected = SUBWORD(thisline,2,1)
  267.             if selected = value then do
  268.                 NOP
  269.             end
  270.             else do
  271.             x = LineOut(outfile,thisline)
  272.             end
  273.     end
  274.   x = stream(outfile,'c','close')
  275.   x = stream(infile,'c','close')
  276.  
  277.     "copy C:\LANSPOOL\CONFIG\CONFIG.DAT C:\LANSPOOL\CONFIG\CONFIG.EMG"
  278.     "copy C:\LANSPOOL\CONFIG\CONFIG.DEL C:\LANSPOOL\CONFIG\CONFIG.DAT"
  279.     "erase C:\LANSPOOL\CONFIG\CONFIG.DEL"
  280. call VRMessage VRWindow(), "ITEM DELETED FROM THE CONFIG FILE."
  281. say "CLASS DELETED FROM SCHEDULE FILE: " selected
  282.  
  283.        
  284. return
  285.  
  286. /*:VRX         PB_11_Click
  287. */
  288. PB_11_Click: 
  289.   ok = VRFileExists( "C:\LANSPOOL\CONFIG\CONFIG.DAT" )  
  290.   IF ok = 1 then do
  291.         NOP
  292.     end
  293.     else do
  294.         id = VRMessage( VRWindow(), "There is no Configuration File defined. Please add a definition, then restart this program!", "Missing configuration file", "Warning", , WILL DO!,  )
  295.         return
  296.     end
  297.  
  298. "Copy C:\LANSPOOL\CONFIG\CONFIG.DAT C:\LANSPOOL\CONFIG\CONFIG.SEE"
  299. "E C:\LANSPOOL\CONFIG\CONFIG.SEE"
  300. return
  301.  
  302. /*:VRX         PB_12_Click
  303. */
  304. PB_12_Click: 
  305.      call Config_Close
  306.  
  307. return
  308.  
  309. /*:VRX         PB_9_Click
  310. */
  311. PB_9_Click: 
  312.  
  313. VSELST = VRGet( "SPIN_1", "Value" )
  314. SERVER = VRGet( "EF_1", "Value" )
  315. DIR = VRGet( "EF_2", "Value" )
  316. NETDR = VRGet( "SPIN_2", "Value" )
  317.  
  318. event = "VSELST "||VSELST NETDR "\\"||SERVER||"\"||DIR 
  319.  
  320. /* Now append event to schedular file */
  321. okay = LINEOUT("C:\LANSPOOL\CONFIG\CONFIG.DAT",event)
  322.     if okay = "1" then do
  323.         say "ERROR WRITING "||event||" to the config file!"
  324.         okay = LINEOUT("C:\LANSPOOL\CONFIG\CONFIG.DAT") /* Close the file */ 
  325.         return
  326.     end
  327. okay = LINEOUT("C:\LANSPOOL\CONFIG\CONFIG.DAT") /* Close the file */
  328. say "EVENT ADDED: "||event
  329. call VRMessage VRWindow(), "ITEM ADDED TO CONFIG FILE."
  330.  
  331. okay = "C:\LANSPOOL\CLASS"||VSELST
  332.     If ok = VRIsDir( "C:\LANSPOOL\CLASSN" ) then do
  333.         NOP
  334.     end
  335.     else do
  336.     okay = "MKDIR "||okay
  337.     okay
  338. end
  339.  
  340.  
  341.  
  342. return
  343.  
  344. /*:VRX         PB_STATUS_Click
  345. */
  346. PB_STATUS_Click: 
  347.  
  348. return
  349.  
  350. /*:VRX         Quit
  351. */
  352. Quit:
  353.     window = VRWindow()
  354.     call VRSet window, "Shutdown", 1
  355.     drop window
  356. return
  357.  
  358. /*:VRX         REFRESH
  359. */
  360. REFRESH: 
  361. /* Process file here */
  362.      button = "CHECKING FOR LST ENTRIES"
  363.      ok = VRSet( "PB_STATUS", "Caption", button )
  364.  
  365.  
  366.     filecnt = "0"
  367.     Lstfil = "C:\LANSPOOL\CONFIG\CONFIG.DAT" 
  368.     LINEIN(Lstfil,1,0)
  369.     
  370.  
  371. /* load all entries */
  372. Do until LINES(Lstfil) = "0"
  373.        goahead = "YES"
  374.        item = LINEIN(Lstfil)
  375.        Lstclass  = SubWord( item, 2, 1 )
  376.        Netdrive = SubWord( item, 3, 1 )
  377.        Netuse = SubWord( item, 3, 2 )
  378.        Netuse = "NET Use "||Netuse  
  379.         
  380.         Remdrive = " NET USE "||Netdrive||" /d"
  381.         Remdrive
  382.         Netuse
  383.       
  384.         if rc = 0 then do
  385.         NOP
  386.         end
  387.         else do
  388.         SAY "Unable to establish network connection for"
  389.         SAY "Will not process config definition for VSE LST CLASS="||Lstclass
  390.         goahead = "NO"
  391.         end
  392.  
  393.         fileout = "C:\LANSPOOL\RDR"||Lstclass
  394.         ok = VRFileExists( fileout )
  395.         if ok = 1 then do
  396.         remove = "ERASE "||fileout
  397.         remove
  398.         end
  399.  
  400.         /* GET VSE LST QUE ENTRIES */
  401.         if goahead = "NO" then do
  402.         NOP
  403.         end
  404.         else do
  405.         usercom = "D LST,"||Lstclass
  406.         command = "RECEIVE "||Fileout||" TS (FILE=PCMD) "||usercom
  407.         "start /win/c/b/min c:\LANSPOOL\getlst.cmd" command "<con >con"
  408.         Call SysSleep 10
  409.         end
  410.               
  411.         ok = VRFileExists( fileout )
  412.           
  413.         if ok = 0 then do /* didn't get anything */
  414.         NOP
  415.         end
  416.         else do
  417.         SAY "GOT QUEUE ENTRIES FOR VSE/ESA LST CLASS = "||Lstclass
  418.         button = "GOT LST CLASS = "||Lstclass
  419.         ok = VRSet( "PB_STATUS", "Caption", button )
  420.         CALL Postfile netdrive
  421.         end
  422.  
  423. end
  424.  
  425. x = stream(lstfil,'c','close')
  426. Postit = "ENDLIST"
  427. CALL LineOut "QUEUE:", Postit
  428. SAY "*****TOTAL FILE GET REQUESTS POSTED FOR THIS PEEK AT LIST QUEUES = "||filecnt
  429. button = "LST ENTRIES TO DO = "||filecnt
  430.         ok = VRSet( "PB_STATUS", "Caption", button )
  431.  
  432.  
  433. return
  434.  
  435. Postfile:
  436.     parse arg netdrive
  437.  
  438.     /* Process VSE list que entries  here */
  439.  
  440.     CALL RxQueue "Set", "Getque"
  441.     LINEIN(Fileout,1,0)
  442.     item = LINEIN(Fileout) /* BYPASS HEADER LINE */
  443.  
  444.     Do until LINES(Fileout) = "0"
  445.        item = LINEIN(Fileout)
  446.        Jobname  = SubWord( item, 2, 1 )
  447.        Jobnum = SubWord( item, 3, 1 )
  448.        Numpge = SubWord( item, 7, 1 )
  449.        Postit = "FILE" Jobname Jobnum Numpge Netdrive
  450.        /* SAY "POSTING="Postit */
  451.        CALL LineOut "QUEUE:", Postit
  452.        Filecnt = Filecnt +1
  453.     end
  454.     Postit = "ENDCLASS "||Lstclass
  455.     CALL LineOut "QUEUE:", Postit
  456.   x = stream(Fileout,'c','close')
  457. return
  458. /*:VRX         TM_1_Trigger
  459. */
  460. TM_1_Trigger: 
  461. time = Time( "C" )
  462. ok = VRSet( "PB_1", "Caption", time )
  463. ok  = Beep( 255, 255 )
  464. ok = VRSet( "TM_1", "Enabled", 0 ) /* DISABLE TRIGGER */
  465. CALL RxQueue "Set","Gotque"
  466. lines = Queued()
  467.  
  468. select
  469.     when timecount > 29 then do
  470.     SAY "SELECTED INTERVENE"
  471.     CALL INTERVENE
  472.     end
  473.     when lines > 0  then do
  474.     CALL GOTONE
  475.     end
  476.     when waiting = "YES" then do
  477.     timecount = timecount + 1
  478.     end
  479.     when waiting = "NO" then do
  480.     CALL STARTNEW
  481.     end
  482.     otherwise do
  483.     NOP
  484.     end
  485. end
  486.  
  487. ok = VRSet( "TM_1", "Enabled", 1 ) /* REENABLE TRIGGER */
  488. ok = VRSet( "TM_1", "Delay", 5000 )
  489.  
  490. return
  491.  
  492. GOTONE:
  493. timecount = 0
  494. waiting = "NO"
  495. task = LineIn("QUEUE:")
  496.  
  497.     CALL RxQueue "Set","taskque"
  498.     lines = Queued()
  499.     If lines > 0 then do
  500.         task = LineIn("QUEUE:")
  501.     end
  502.  
  503. taskdone = SubWord( task,1,1 )
  504. select
  505.  
  506.     when taskdone = "FILE" then do
  507.     CALL POSTDEL
  508.     end
  509.  
  510.     when taskdone = "ENDCLASS" then do
  511.     class = SubWord( task,2,1 )
  512.     button = "DID LST CLASS = "||class
  513.     ok = VRSet( "PB_STATUS", "Caption", button )
  514.     time = Time( "C" )
  515.         SAY time||" Completed processing the LST CLASS="||class
  516.     CALL STARTNEW
  517.     end
  518.  
  519.     when taskdone = "ENDLIST" then do
  520.     button = "DID ALL ENTRIES"
  521.     ok = VRSet( "PB_STATUS", "Caption", button )
  522.     time = Time( "C" )
  523.     SAY time||" Completed processing ALL LST CLASSES"
  524.     SAY "Will check for new listing"
  525.     CALL REFRESH
  526.      If Filecnt = 0 then do
  527.         SAY "THERE ARE NO FILES IN SELECTED LST QUEUE TO PROCESS"
  528.         time = Time( "C" )
  529.         SAY time||" ENDING PROGRAM NOW.........................."
  530.         call Quit
  531.         call Fini
  532.      end
  533.     waiting = "NO"
  534.     timecount = 0
  535.     end
  536.     otherwise do
  537.     NOP
  538.     end
  539.  end
  540. return
  541.  
  542. POSTDEL:
  543. jobname = SubWord(task,2,1)
  544. jobnum = SubWord(task,3,1)
  545. netdrive = SubWord(task,4,1)
  546.  
  547. /* Did we get it ? */
  548. checkfile = "C:\LANSPOOL\LISTS\"||jobname
  549. ok = VRFileExists( checkfile )
  550.  
  551. IF ok = "1" then do
  552.     button = "GOT LISTING "
  553.     button = button||jobname
  554.     button = button jobnum
  555.     ok = VRSet( "PB_STATUS", "Caption", button )
  556.     usercom = "L LST,"||jobname||","||jobnum
  557.     command = "RECEIVE C:\LANSPOOL\RESULTS TS (FILE=PCMD) "||usercom
  558.     SAY "DELETING RECEIVED FILE FROM LST QUEUE: "||jobname
  559.     "start /win/c/b/min c:\LANSPOOL\WORKERBE.cmd" command "<con >con"
  560.      FLE = "DEL" jobname jobnum
  561.     Call RxQueue "Set","taskque"
  562.     CALL LineOut "QUEUE:", FLE
  563.     waiting = "YES"
  564.     timecount = 0 
  565.     x = RANDOM(0,999)
  566.     flname = "C:\LANSPOOL\LISTS\"||jobname
  567.     transfer = "COPY "||flname||" "||netdrive||"\"jobname||"."||x
  568.     time = Time( "C" )
  569.     SAY time||" EXECUTING: "transfer
  570.     transfer
  571.         if RC = 0 then do
  572.             button = "Delivered file "
  573.             button = button||jobname
  574.             button = button||"."
  575.             button = button||x
  576.             ok = VRSet( "PB_STATUS", "Caption", button )
  577.             remove = "ERASE "flname
  578.             time = Time( "C" )
  579.             SAY time||" EXECUTING: "remove
  580.             remove
  581.         end
  582. end
  583. return
  584.  
  585. STARTNEW:
  586. Call RxQueue "Set", "Getque"
  587. FLE = LineIn("QUEUE:")
  588. SAY "PROCESSING: "||FLE
  589. What = SubWord(FLE,1,1)
  590.     select
  591.         when What = "ENDCLASS" then do
  592.             Call RxQueue "Set","Gotque"
  593.             CALL LineOut "QUEUE:", FLE
  594.         end
  595.         when What = "ENDLIST"  then do
  596.             Call RxQueue "Set","Gotque"
  597.             CALL LineOut "QUEUE:", FLE
  598.         end
  599.         when What = "FILE"  then do
  600.             jobname = SubWord(FLE,2,1)
  601.             jobnum = SubWord(FLE,3,1)
  602.             netdrive = SubWord(FLE,5,1)
  603.         command = "RECEIVE C:\LANSPOOL\LISTS\"||jobname jobname jobnum||" (file=lst"
  604.         "start /win/c/b/min c:\LANSPOOL\WORKERBE.cmd" command "<con >con"
  605.         FLE = "FILE " jobname jobnum netdrive
  606.         Call RxQueue "Set","taskque"
  607.         CALL LineOut "QUEUE:", FLE
  608.  
  609.         waiting = "yes"
  610.         timecount = 0
  611.         end
  612.         otherwise do
  613.         end
  614.      end
  615.     
  616. return
  617.  
  618. INTERVENE:
  619. ok = VRSet( "PB_STATUS", "BackColor", "Red" )
  620. ok = VRSet( "PB_STATUS", "Caption", "STOPPED!" )
  621.     do 30
  622.     ok  = Beep( 255, 255 )
  623.     ok  = Beep( 100, 100 )
  624.     ok  = Beep( 255, 255 )
  625.     end
  626. SAY "*****THERE MAY BE A COMMUNICATIONS SESSION PROBLEM"
  627. SAY "*****WILL DELETE QUES AND QUIT OUT NOW************"
  628. call Quit
  629. call Fini
  630. return
  631. /*:VRX         Window1_Close
  632. */
  633. Window1_Close:
  634.     call Quit
  635. return
  636.  
  637.