home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / iwzmine.lxl < prev    next >
Text File  |  1997-12-17  |  10KB  |  288 lines

  1. /* Reinvoking as "REXX %0 %1 %2 %3 %4 %5 %6 %7 %8 %9"  2>nul
  2. @goto runit */
  3. /*********************************************************************/
  4. /* Licensed Material - Property of IBM                               */
  5. /* 5639-B92 , 5639-D65 (C) Copyright IBM Corp., 1997, 1998           */
  6. /* All rights reserved.                                              */
  7. /* US Government Users Restricted Rights - Use, duplication or       */
  8. /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */
  9. /*********************************************************************/
  10. trace off;
  11. signal on novalue;
  12. parse source opsys . whoami rest;
  13. /* cobolroot is now set by iwzmIR.CMD */
  14. if opsys = 'OS/2' then
  15.   do;
  16.   env = 'OS2ENVIRONMENT';
  17.   callit = '@Call';
  18.   call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs';
  19.   call SysLoadFuncs;
  20.   end;
  21. else
  22.   do;
  23.   env = 'ENVIRONMENT';
  24.   callit = '@Rexx';
  25.   end;
  26. tempdir = value('TMP',,env);
  27. tempout = SysTempFileName(tempdir'\TM?????.OUT');
  28. tempout2 = SysTempFileName(tempdir'\T2?????.OUT');
  29. xx = Get_MVSINFO();
  30. if xx <> 0 then
  31.   exit 16;
  32. call Set_MVSINFO_Vars;
  33. if tracemod = '*' |,
  34.   wordpos(translate(substr(whoami,lastpos('\',whoami)+1)),tracemod) > 0 then
  35.   do;
  36.   if trace > 3 then trace results;
  37.   if trace > 4 then trace ?;
  38.   end;
  39. parse arg the_input_args;
  40. call traceit 1 'Entry' '!'the_input_args'!';
  41.  
  42. parse upper arg errfile rest;
  43.  
  44. 'extract classes into classes';
  45. call traceit 3 'classes=' classes;
  46. if wordpos('MESSAGE',classes) > 0 then /* error messages already shown in this edit session */
  47.   'emsg delete'  /* get rid of them, they're out of date */
  48. else 'set classes' classes 'MESSAGE';
  49.  
  50. /* info about edit session  */
  51. 'check';
  52. 'extract changes into changes';
  53. 'extract readonly into readonly';
  54. 'extract highlight into highlight';
  55. 'extract limiterror'; /* this is the parameter that determines whether an
  56.                          error message is issued when a line that's too long
  57.                          is inserted */
  58. 'set readonly off';
  59. 'set highlight' highlight 'MESSAGE';
  60. 'set limiterror ignore' /* inserted messages may be too long - suppress lpex
  61.                            error message */
  62. call traceit 3 'set limiterror to ignore';
  63.  
  64. /* Find first line that isn't an MVS info message */
  65. 'extract elements';  /* number of lines in the file */
  66. 'top';
  67. do strtdata = 1 to elements until wordpos('MVSMSG',class) = 0
  68.   'extract class'
  69.   if wordpos('MVSMSG',class) <> 0 then 'next'
  70.   call traceit 3 'inside loop, strtdata and class are' strtdata class;
  71. end
  72. call traceit 3 'strtdata and elements are' strtdata elements;
  73.  
  74. /* On exiting this loop, strtdata is the linenumber of the first line with data
  75. (source code).  Need to know this in order to put error messages with correct lines.
  76. variable lineshift is the number of lines by which everything has shifted. */
  77. lineshift = strtdata - 1
  78.  
  79. inline = linein(errfile) /* read the first line in the error message file */
  80. inline = translate(inline) /* fold to upper case */
  81. parse var inline 'LINENUMBER' posline /* posline is the source linenumber for the error msg the user clicked */
  82.  
  83. 'setoldlines';
  84. do while lines(errfile) <> 0 /* read through error message file */
  85.   inline = linein(errfile)
  86.   parse var inline stuff1'('srcline':' stuff2 /* get the source line number from the error msg */
  87.   call addmsg srcline inline; /* insert the message into the source file */
  88. end /* end loop through error message file */
  89.  
  90. /* set up menu bar for error messages */
  91. 'SET ACTIONBAR.LP_VIEW.SEPARATOR 2'
  92. 'SET ACTIONBAR.LP_VIEW.Messa~ges 3 ;SET EXCLUDE; SET INCLUDE MESSAGE; SET VIEWNAME Messages'
  93. 'SET ACTIONBAR.LP_ACTIONS.~Next_error EMSG NEXT'
  94. 'SET ACCELERATOR. A-N'
  95. 'SET ACTIONBAR.LP_ACTIONS.P~revious_error EMSG UP'
  96. 'SET ACCELERATOR. A-X'
  97. 'SET ACTIONBAR.LP_ACTIONS.~Delete_messages EMSG DELETE'
  98.  
  99. /* reset state of lpex session */
  100. 'set readonly' readonly;
  101. 'check';
  102. 'set changes' changes;
  103. 'set limiterror' limiterror
  104. 'sshow';
  105.  
  106. /* position current line for user's lpex session */
  107. if lineshift > 0 then 'find element 1' /* if there are MVS info messages, position at top so they are seen */
  108. else 'find oldline' posline; /* position at source for error message user clicked on */
  109.  
  110. /* cleanup */
  111. rc = stream(errfile,'c','close')
  112. rc = SysFileDelete(errfile)
  113. call traceit 3 'Deleting' errfile 'with rc' rc;
  114. call traceit 1 'Normal exit';
  115. exit 0;
  116.  
  117. /* */
  118. addmsg:
  119. parse arg row themsg;
  120. lpexrow = row+lineshift /* account for line shift caused by MVS info messages */
  121. 'find oldline' lpexrow
  122. 'extract content'
  123. call traceit 3 row lpexrow content;
  124.  
  125. /* If this is the error message the user doubleclicked on, keep track of the source line
  126.    so we can position to it in the user's lpex session */
  127. if row = posline  then 'set oldline' posline
  128.  
  129. 'insert' themsg;
  130. 'set show on';
  131. 'set class message';
  132.  
  133. return;
  134. /* */
  135.  
  136. errmsg:
  137. parse arg the_msg;
  138. 'msg' the_msg;
  139. 'alarm';
  140. exit 16;
  141.  
  142. Get_MVSINFO:
  143. Procedure expose env cobolroot mvsinfo. whoami tempdir trace
  144.  
  145. rtn = 0
  146. null = '0000'x
  147. crlf = '0D0A'x
  148. mvsinfo. = ''
  149. mvsinfoQ = translate('iwzm_MVSINFO.DAT_YALE');
  150.  
  151. oldq = rxqueue('Set',mvsinfoQ)   /* switch to mvsinfo queue */
  152. if queued() = 0 then do                   /* if Q is missing we'll */
  153.   qname = rxqueue('Create',mvsinfoQ)      /* create it and put a bad */
  154.   if qname = mvsinfoQ then push 'Sven'    /* timestamp on it, else */
  155.   else x=rxqueue('Delete',qname)          /* it was in use (we hope) */
  156.   end                                     /* so we'll assume we can */
  157. parse pull mvsstuff; push mvsstuff        /* get/replace Q contents */
  158. parse value mvsstuff with ts (null) . cobolroot (null) mvsstuff /* get */
  159.                                         /* timestamp and cobolroot */
  160. if ts <> 'Sven' then do;
  161.   mvsinfo = cobolroot'\MACROS\MVSINFO.DAT'
  162.   bad_mvsinfo = '    **' whoami '****'crlf'    **error*' mvsinfo,
  163.                 'is unavailable, missing or empty **'
  164.  
  165.   x=SysFileTree(mvsinfo,'ts','F')       /* get MVSINFO.DAT's timestamp */
  166.   if ts.0 <> 1 then do
  167.     say bad_mvsinfo
  168.     return 12;
  169.     end
  170.   parse var ts.1 v0 v1 v2 .
  171.   timestamp ='mvsinfo.dat.timestamp' v0 v1 v2
  172.   end;
  173. else
  174.   timestamp = 'Yale'
  175. if timestamp <> ts then do              /* timestamps match? */
  176.   pull mvsstuff                         /* no, remove bad contents */
  177.   rtn = "iwzmIR.CMD"()                /* ask for new stuff */
  178.   if rtn = 0 then do
  179.     parse pull mvsstuff; push mvsstuff    /* get/replace Q contents */
  180.                                         /* remove timestamp and     */
  181.                                         /* cobolroot                */
  182.     parse value mvsstuff with . (null) . cobolroot ( null) mvsstuff
  183.     end
  184.   end
  185. qname = rxqueue('Set',oldq)      /* restore normal queue */
  186.  
  187. do while (mvsstuff<>'') & (rtn=0)   /* mvsinfo. structure */
  188.   parse value mvsstuff with key val (null) mvsstuff
  189.   if mvsinfo.key = '' then do       /* e.g. mvsinfo.TYPE='' */
  190.     mvsinfo.KEYS = mvsinfo.KEYS key /* no substitution for KEYS */
  191.     mvsinfo.key.1 = val             /* e.g. mvsinfo.TYPE.1=val  */
  192.     mvsinfo.key = 1                 /* e.g. mvsinfo.TYPE=1      */
  193.     end
  194.   else do
  195.     x = mvsinfo.key + 1             /* e.g. mvsinfo.TYPE+1     */
  196.     mvsinfo.key.x = val             /* e.g. mvsinfo.TYPE.2=val */
  197.     mvsinfo.key = x                 /* e.g. mvsinfo.TYPE=2     */
  198.     end
  199.   end
  200.  
  201. return rtn
  202.  
  203. Set_MVSINFO_Vars:
  204.  
  205.  parse var mvsinfo.CLOSECMD.1 closecmd;
  206.  parse var mvsinfo.CLOSEFILE.1 closefile;
  207.  parse var mvsinfo.FILESYS.1 filesys accessmon testaccess;
  208.  parse var mvsinfo.FSSTARTCMD.1 fsstartcmd;
  209.  parse var mvsinfo.FSSTOPCMD.1 fsstopcmd;
  210.  parse var mvsinfo.HEADER.1 header;
  211.  parse var mvsinfo.JOBLOG.1 joblog;
  212.  parse var mvsinfo.MAXCMD.1 maxcmd;
  213.  parse var mvsinfo.LANGUAGE.1 language;
  214.  parse var mvsinfo.MOUNTCMD.1 mountcmd;
  215.  parse var mvsinfo.MVSCOMM.1 mvscomm;
  216.  parse var mvsinfo.iwzmEDT.1 iwzmedt;
  217.  parse var mvsinfo.NFS.1 nfs;
  218.  parse var mvsinfo.NULLSTDIN.1 nullstdin;
  219.  parse var mvsinfo.OUTSHOW.1 outshow;
  220.  parse var mvsinfo.PROTSAVE.1 protsave tempmult;
  221.  parse var mvsinfo.PWD.1 pwd pwdasis pwdt pwde;
  222.  parse var mvsinfo.READTIMEOUT.1 readtimeout;
  223.  parse var mvsinfo.REXECCMD.1 rexeccmd;
  224.  parse var mvsinfo.SDU.1 sdu;
  225.  parse var mvsinfo.SIGYCLST.1 sigyclst;
  226.  parse var mvsinfo.SYSPROC.1 sysproc;
  227.  parse var mvsinfo.SYSTEM.1 system;
  228.  parse var mvsinfo.TEMPDRIVE.1 tempdrive;
  229.  parse var mvsinfo.TEMPDATA.1 tempdata;
  230.  parse var mvsinfo.TESTFILE.1 testfile;
  231.  parse var mvsinfo.TRACE.1 trace tracekeep;
  232.  parse var mvsinfo.TRACECMD.1 tracecmd;
  233.  parse var mvsinfo.TRACEMOD.1 tracemod;
  234.  parse var mvsinfo.UMOUNTCMD.1 umountcmd;
  235.  parse var mvsinfo.USERID.1 userid;
  236.  parse var mvsinfo.WORKSYS.1 worksys;
  237.  parse var mvsinfo.WRITETIMEOUT.1 writetimeout;
  238.  
  239.  parse var mvsinfo.DRIVE numdrive;
  240.  if numdrive = '' then
  241.    numdrive = 0;
  242.  do ii = 1 to numdrive;
  243.    parse var mvsinfo.DRIVE.ii,
  244.              drive.ii highqual.ii trans.ii mapping.ii sidefile.ii;
  245.    end;
  246.  
  247.  parse var mvsinfo.TYPE numtype;
  248.  if numtype = '' then
  249.    numtype = 0;
  250.  do ii = 1 to numtype;
  251.    parse var mvsinfo.TYPE.ii type.ii ext.ii;
  252.    end;
  253.  
  254. return
  255.  
  256. /* */
  257. Traceit:
  258.  parse arg iwz_trc_level iwz_trc_message;
  259.  if iwz_trc_level > trace then
  260.    return;
  261.  if pwd <> '********' & pwd <> '++++++++' & pwd <> '========' then
  262.    do;
  263.    do forever;
  264.      if pos(pwd,iwz_trc_message) = 0 then
  265.        leave;
  266.      parse var iwz_trc_message iwz_trc_message1 (pwd) iwz_trc_message2;
  267.      iwz_trc_message = iwz_trc_message1||'********'||iwz_trc_message2
  268.      end;
  269.    end
  270.  iwz_trc_message = date('O') time('L') whoami':' iwz_trc_message;
  271.  xx = lineout(tempdir'\iwzmTRC.TRC',iwz_trc_message);
  272.  xx = stream(tempdir'\iwzmTRC.TRC','C','CLOSE');
  273.  if tracecmd <> '' then
  274.    interpret tracecmd;
  275. return;
  276.  
  277. /* */
  278. sayit:
  279.  parse arg iwz_sayit_arg;
  280.  if trace > 2 then
  281.    call traceit 3 '--->' iwz_sayit_arg;
  282.  say iwz_sayit_arg;
  283. return;
  284. /*
  285. :runit
  286. @rexx %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
  287. @rem */
  288.