home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / iwzmems.lxl < prev    next >
Text File  |  1997-12-30  |  9KB  |  270 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. /* get the name of the source file, and the source line number for the error message
  42.    on the current line */
  43. numsources = 0
  44. cursourcenm = ''
  45. curlinenum = ''
  46. 'extract class'
  47. call traceit 3 'class of current line is' class
  48. if wordpos('MESSAGE',class) <> 0 then
  49.   do
  50.     'extract content'
  51.     parse var content cursourcenm'('curlinenum':'rest
  52.     call traceit 3 content
  53.     call traceit 3 cursourcenm curlinenum
  54.   end
  55.  
  56. /* pull out all the error messages and put into files for use by iwzmine.lxl.
  57.    Each different source file gets its own error message file */
  58. /* put the error msgs into the file in reverse order.  this means iwzmine.lxl will insert
  59.    them from the bottom up, and source line numbers won't need to be constantly adjusted. */
  60. numsources = 0
  61. 'extract elements' /*get number of lines in the monitor */
  62. 'bottom' /* position at the bottom of the monitor */
  63. call traceit 3 'number of lines in monitor is' elements
  64. do i = elements to 1 by -1
  65.   'extract class'
  66.   call traceit 3 i class
  67.   if wordpos('MESSAGE',class) <> 0  then/* this is a message */
  68.     do
  69.       'extract content'
  70.       parse var content insource'('inline':'rest /* pull out source name and line number */
  71.       sourcenum = findsrc(insource,inline) /* find or add sourcename to list */
  72.       call lineout errfile.sourcenum, content /* put the content of the error message into
  73.                                                 errfile */
  74.     end
  75.   'prev' /* move on to the next line up */
  76. end /* loop up through messages */
  77.  
  78. do i = 1 to numsources /* bring up an edit session for each source with messages */
  79.   call command 'iwzmedt.cmd' sourcenm.i 'RW' errfile.i
  80. end
  81. call traceit 1 'Normal exit';
  82. exit 0;
  83.  
  84. /* */
  85. findsrc:
  86. parse arg sn ln; /* input sourcename and linenumber */
  87. call traceit 3 'findsrc' sn ln
  88. do j = 1 to numsources while sn <> sourcenm.j  /* have we seen this sourcename before? */
  89. end
  90. if j > numsources then /* first time for this sourcename */
  91.   do
  92.     numsources = numsources + 1
  93.     sourcenm.numsources = sn
  94.     errfile.numsources = SysTempFileName(tempdir'\iwzm????.msg') /* get unique name for the error msg file */
  95.     if sourcenm.numsources = cursourcenm then /* was the current line in the monitor an error
  96.                                                  msg for this source? */
  97.       call lineout errfile.numsources, 'linenumber' curlinenum /* pass along the line number */
  98.     else /* monitor focus was elsewhere - will position at the top of the source */
  99.       call lineout errfile.numsources, 'linenumber 1'
  100.  
  101.   end
  102. else nop /* seen this sourcename before */
  103.  
  104. call traceit 3 j sourcenm.j errfile.j
  105.  
  106. return j;
  107.  
  108. /* */
  109. command:
  110. parse arg thecmd;
  111. call traceit 3 thecmd
  112. if opsys = 'OS/2' then
  113.   address cmd '@start /c /i' thecmd;
  114. else
  115.   address cmd '@start /i rexx' thecmd;
  116. return;
  117.  
  118. /* */
  119. errmsg:
  120. parse arg the_msg;
  121. 'msg' the_msg;
  122. 'alarm';
  123. exit 16;
  124. Get_MVSINFO:
  125. Procedure expose env cobolroot mvsinfo. whoami tempdir trace
  126.  
  127. rtn = 0
  128. null = '0000'x
  129. crlf = '0D0A'x
  130. mvsinfo. = ''
  131. mvsinfoQ = translate('iwzm_MVSINFO.DAT_YALE');
  132.  
  133. oldq = rxqueue('Set',mvsinfoQ)   /* switch to mvsinfo queue */
  134. if queued() = 0 then do                   /* if Q is missing we'll */
  135.   qname = rxqueue('Create',mvsinfoQ)      /* create it and put a bad */
  136.   if qname = mvsinfoQ then push 'Sven'    /* timestamp on it, else */
  137.   else x=rxqueue('Delete',qname)          /* it was in use (we hope) */
  138.   end                                     /* so we'll assume we can */
  139. parse pull mvsstuff; push mvsstuff        /* get/replace Q contents */
  140. parse value mvsstuff with ts (null) . cobolroot (null) mvsstuff /* get */
  141.                                         /* timestamp and cobolroot */
  142. if ts <> 'Sven' then do;
  143.   mvsinfo = cobolroot'\MACROS\MVSINFO.DAT'
  144.   bad_mvsinfo = '    **' whoami '****'crlf'    **error*' mvsinfo,
  145.                 'is unavailable, missing or empty **'
  146.  
  147.   x=SysFileTree(mvsinfo,'ts','F')       /* get MVSINFO.DAT's timestamp */
  148.   if ts.0 <> 1 then do
  149.     say bad_mvsinfo
  150.     return 12;
  151.     end
  152.   parse var ts.1 v0 v1 v2 .
  153.   timestamp ='mvsinfo.dat.timestamp' v0 v1 v2
  154.   end;
  155. else
  156.   timestamp = 'Yale'
  157. if timestamp <> ts then do              /* timestamps match? */
  158.   pull mvsstuff                         /* no, remove bad contents */
  159.   rtn = "iwzmIR.CMD"()                /* ask for new stuff */
  160.   if rtn = 0 then do
  161.     parse pull mvsstuff; push mvsstuff    /* get/replace Q contents */
  162.                                         /* remove timestamp and     */
  163.                                         /* cobolroot                */
  164.     parse value mvsstuff with . (null) . cobolroot ( null) mvsstuff
  165.     end
  166.   end
  167. qname = rxqueue('Set',oldq)      /* restore normal queue */
  168.  
  169. do while (mvsstuff<>'') & (rtn=0)   /* mvsinfo. structure */
  170.   parse value mvsstuff with key val (null) mvsstuff
  171.   if mvsinfo.key = '' then do       /* e.g. mvsinfo.TYPE='' */
  172.     mvsinfo.KEYS = mvsinfo.KEYS key /* no substitution for KEYS */
  173.     mvsinfo.key.1 = val             /* e.g. mvsinfo.TYPE.1=val  */
  174.     mvsinfo.key = 1                 /* e.g. mvsinfo.TYPE=1      */
  175.     end
  176.   else do
  177.     x = mvsinfo.key + 1             /* e.g. mvsinfo.TYPE+1     */
  178.     mvsinfo.key.x = val             /* e.g. mvsinfo.TYPE.2=val */
  179.     mvsinfo.key = x                 /* e.g. mvsinfo.TYPE=2     */
  180.     end
  181.   end
  182.  
  183. return rtn
  184.  
  185. Set_MVSINFO_Vars:
  186.  
  187.  parse var mvsinfo.CLOSECMD.1 closecmd;
  188.  parse var mvsinfo.CLOSEFILE.1 closefile;
  189.  parse var mvsinfo.FILESYS.1 filesys accessmon testaccess;
  190.  parse var mvsinfo.FSSTARTCMD.1 fsstartcmd;
  191.  parse var mvsinfo.FSSTOPCMD.1 fsstopcmd;
  192.  parse var mvsinfo.HEADER.1 header;
  193.  parse var mvsinfo.JOBLOG.1 joblog;
  194.  parse var mvsinfo.MAXCMD.1 maxcmd;
  195.  parse var mvsinfo.LANGUAGE.1 language;
  196.  parse var mvsinfo.MOUNTCMD.1 mountcmd;
  197.  parse var mvsinfo.MVSCOMM.1 mvscomm;
  198.  parse var mvsinfo.iwzmEDT.1 iwzmedt;
  199.  parse var mvsinfo.NFS.1 nfs;
  200.  parse var mvsinfo.NULLSTDIN.1 nullstdin;
  201.  parse var mvsinfo.OUTSHOW.1 outshow;
  202.  parse var mvsinfo.PROTSAVE.1 protsave tempmult;
  203.  parse var mvsinfo.PWD.1 pwd pwdasis pwdt pwde;
  204.  parse var mvsinfo.READTIMEOUT.1 readtimeout;
  205.  parse var mvsinfo.REXECCMD.1 rexeccmd;
  206.  parse var mvsinfo.SDU.1 sdu;
  207.  parse var mvsinfo.SIGYCLST.1 sigyclst;
  208.  parse var mvsinfo.SYSPROC.1 sysproc;
  209.  parse var mvsinfo.SYSTEM.1 system;
  210.  parse var mvsinfo.TEMPDRIVE.1 tempdrive;
  211.  parse var mvsinfo.TEMPDATA.1 tempdata;
  212.  parse var mvsinfo.TESTFILE.1 testfile;
  213.  parse var mvsinfo.TRACE.1 trace tracekeep;
  214.  parse var mvsinfo.TRACECMD.1 tracecmd;
  215.  parse var mvsinfo.TRACEMOD.1 tracemod;
  216.  parse var mvsinfo.UMOUNTCMD.1 umountcmd;
  217.  parse var mvsinfo.USERID.1 userid;
  218.  parse var mvsinfo.WORKSYS.1 worksys;
  219.  parse var mvsinfo.WRITETIMEOUT.1 writetimeout;
  220.  
  221.  parse var mvsinfo.DRIVE numdrive;
  222.  if numdrive = '' then
  223.    numdrive = 0;
  224.  do ii = 1 to numdrive;
  225.    parse var mvsinfo.DRIVE.ii,
  226.              drive.ii highqual.ii trans.ii mapping.ii sidefile.ii;
  227.    end;
  228.  
  229.  parse var mvsinfo.TYPE numtype;
  230.  if numtype = '' then
  231.    numtype = 0;
  232.  do ii = 1 to numtype;
  233.    parse var mvsinfo.TYPE.ii type.ii ext.ii;
  234.    end;
  235.  
  236. return
  237.  
  238. /* */
  239. Traceit:
  240.  parse arg iwz_trc_level iwz_trc_message;
  241.  if iwz_trc_level > trace then
  242.    return;
  243.  if pwd <> '********' & pwd <> '++++++++' & pwd <> '========' then
  244.    do;
  245.    do forever;
  246.      if pos(pwd,iwz_trc_message) = 0 then
  247.        leave;
  248.      parse var iwz_trc_message iwz_trc_message1 (pwd) iwz_trc_message2;
  249.      iwz_trc_message = iwz_trc_message1||'********'||iwz_trc_message2
  250.      end;
  251.    end
  252.  iwz_trc_message = date('O') time('L') whoami':' iwz_trc_message;
  253.  xx = lineout(tempdir'\iwzmTRC.TRC',iwz_trc_message);
  254.  xx = stream(tempdir'\iwzmTRC.TRC','C','CLOSE');
  255.  if tracecmd <> '' then
  256.    interpret tracecmd;
  257. return;
  258.  
  259. /* */
  260. sayit:
  261.  parse arg iwz_sayit_arg;
  262.  if trace > 2 then
  263.    call traceit 3 '--->' iwz_sayit_arg;
  264.  say iwz_sayit_arg;
  265. return;
  266. /*
  267. :runit
  268. @rexx %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
  269. @rem */
  270.