home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / fgrexx10.zip / fgrexx.cmd
OS/2 REXX Batch file  |  1999-05-28  |  2KB  |  61 lines

  1. /* fgrexx.cmd, v1.0 1999-05-28, A.Koos */ 
  2. /* Makes himself(more exactly:the parent cmd.exe) to be the foreground process. */
  3. /* Uses the 'go.exe' by Carsten Wimmer.The go.exe must be in the same dir as    */
  4. /* fgrexx.cmd.Tested on Warp 4 in OREXX. Contact: akoos@mvm.hu                  */
  5.  
  6. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  7. call SysLoadFuncs
  8.  
  9. Arg sleep
  10.  
  11. if datatype(sleep,'W')=0 then sleep=10;
  12.  
  13. parse source . . progpath
  14. gopath=translate(filespec('drive',progpath)||filespec('path',progpath)||'go.exe');
  15.  
  16. call SysFileTree gopath,files.,'F'
  17. if files.0=0 then do
  18.         say 'GO.EXE is not found in the startup directory!'
  19.         '@pause'
  20.         Exit;
  21. end;
  22.  
  23.  
  24. say 'Waiting.Now,you can make other program running in the foreground.';
  25. say 'Switching in 'sleep' seconds.'
  26. call SysSleep sleep
  27.  
  28.  rtcd= FGSwitching()
  29.  
  30. if rtcd then say 'Hello,I am here!';
  31.  
  32. EXIT;
  33.  
  34. /*----------------------------------------------------*/
  35. /* You can copy this procedure source into your code  */
  36. /* probably without any modification.                 */
  37. FGSwitching: procedure
  38.  
  39. nul='>nul 2>&1'
  40. parse source . . progpath
  41. gopath=translate(filespec('drive',progpath)||filespec('path',progpath)||'go.exe');
  42.  
  43. call SysFileTree gopath,files.,'F'
  44. if files.0=0 then return .false; /* 'GO.EXE is not found in the startup directory!'*/
  45.  
  46. '@'||gopath||' -lpl|rxqueue'
  47.  
  48. do while queued()>0
  49.    str=translate(linein('QUEUE:'));
  50.    if  pos(gopath,str)>0 then do
  51.          parse var str PID PPID .
  52.    end;
  53. end /* do */
  54. if var('PPID')=0 then return .false;
  55.  
  56. '@'||gopath||' -j '||PPID nul
  57.  
  58. return .true;
  59. /*-------------------------------------*/
  60.  
  61.