home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / iwzmusq.lx < prev    next >
Text File  |  1998-02-10  |  11KB  |  355 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. parse upper arg request restu;
  42. parse arg dummy rest;
  43. 'extract docnum into docnum';
  44. 'extract actionbarid.~Options.Cols_73-80_separate into menunum';
  45. 'extract actionbarid.~Options.Propagate_cols_73-80 into menunump';
  46. if menunum = '' then
  47.   do;
  48.   'set actionbar.~Options.Cols_73-80_separate 98 macro iwzmusq.lx';
  49.   'extract actionbarid.~Options.Cols_73-80_separate into menunum';
  50.   'set actionbar.~Options.Propagate_cols_73-80 99 macro iwzmusq.lx propagate';
  51.   'extract actionbarid.~Options.Propagate_cols_73-80 into menunump';
  52.   'set menuactive.'menunump 'OFF';
  53.   'set global.iwzmusq_propagate_'docnum 'off';
  54.   'extract global.keys into keys';
  55.   if keys <> 'ISPF' & keys <> 'XEDIT' then
  56.     do;
  57.     call traceit 1 'Normal exit';
  58.     exit 0;
  59.     end;
  60.   end;
  61. if request = 'PROPAGATE' then
  62.   do;
  63.   'extract global.iwzmusq_propagate_'docnum 'into propstat';
  64.   if propstat = 'off' then
  65.     do;
  66.     'set global.iwzmusq_propagate_'docnum 'on';
  67.     'set menucheck.'menunump 'ON';
  68.     end;
  69.   else
  70.     do;
  71.     'set global.iwzmusq_propagate_'docnum 'off';
  72.     'set menucheck.'menunump 'OFF';
  73.     end;
  74.   call traceit 1 'Normal exit';
  75.   exit 0;
  76.   end;
  77. if request = 'END' then
  78.   do;
  79.   blanks = '                                        ';
  80.   blanks = blanks||blanks;
  81.   deffont = '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!';
  82.   deffont = deffont||deffont;
  83.   'extract recording into recording';
  84.   'extract content into content';
  85.   content2 = substr(content,1,72);
  86.   content2 = strip(content2,'T');
  87.   'extract position into position';
  88.   if length(content) > 72 then
  89.     do;
  90.     if position < 73 then
  91.       do;
  92.       if position > length(content2) then
  93.         'set position 73';
  94.       else
  95.         do;
  96.         newposition = length(content2) + 1;
  97.         'set position' newposition;
  98.         end;
  99.       end;
  100.     else
  101.       'primitive endline';
  102.     end;
  103.   else
  104.     do;
  105.     if position > length(content2) then
  106.       do;
  107.       if length(content) < 72 then
  108.         do;
  109.         'extract fonts into fonts';
  110.         newcontent = substr(content||blanks,1,72);
  111.         newfonts = substr(fonts||deffont,1,72);
  112.         'set recording off';
  113.         'set content' newcontent;
  114.         'set fonts' newfonts;
  115.         'set recording' recording;
  116.         end;
  117.       'set position 73';
  118.       end;
  119.     else
  120.       do;
  121.       newposition = length(content2) + 1;
  122.       'set position' newposition;
  123.       end;
  124.     end;
  125.   call traceit 1 'Normal exit';
  126.   exit 0;
  127.   end;
  128. if request = 'FIND' then
  129.   do;
  130.   testpos1 = wordpos('ANY',restu);
  131.   testpos2 = wordpos('ASIS',restu);
  132.   select;
  133.     when testpos1 = 0 & testpos2 = 0 then
  134.       testpos = 0;
  135.     when testpos1 = 0 & testpos2 > 0 then
  136.       testpos = pos(' ASIS',' 'restu) - 1;
  137.     when testpos1 > 0 & testpos2 = 0 then
  138.       testpos = pos('ANY',restu);
  139.     when testpos1 > 0 & testpos2 > 0 then
  140.       do;
  141.       if testpos1 < testpos2 then
  142.         testpos = pos('ANY',restu);
  143.       else
  144.         testpos = pos(' ASIS',' 'restu) - 1;
  145.       end;
  146.     otherwise
  147.       testpos = 0;
  148.     end;
  149.   if testpos > 0 then
  150.     do;
  151.     if pos('COLUMNS',restu) = 0 | pos('COLUMNS',restu) > testpos then
  152.       do;
  153.       'extract position into position';
  154.       if position < 73 then
  155.         cols = '1 72'
  156.       else
  157.         cols = '73 80';
  158.       if testpos = 1 then
  159.         findcmd = 'COLUMNS' cols rest;
  160.       else
  161.         do;
  162.         part3 = substr(rest,testpos);
  163.         len = testpos - 1;
  164.         part1 = substr(rest,1,len);
  165.         findcmd = part1 'COLUMNS' cols part3;
  166.         end;
  167.       'lxn find' findcmd;
  168.       find_rc = rc;
  169.       'msg Find on cols' word(cols,1)'-'word(cols,2) 'based on cursor';
  170.       if find_rc = 0 then
  171.         call traceit 1 'Normal exit';
  172.       else
  173.         call traceit 1 'Error exit';
  174.       exit find_rc;
  175.       end;
  176.     end;
  177.   'lxn find' rest;
  178.   find_rc = rc;
  179.   if find_rc = 0 then
  180.     call traceit 1 'Normal exit';
  181.   else
  182.     call traceit 1 'Error exit';
  183.   exit find_rc;
  184.   end;
  185. 'extract menucheck.'menunum 'into check';
  186. if check = 'OFF' then
  187.   do;
  188.   'set menucheck.'menunum 'ON';
  189.   'set menuactive.'menunump 'ON';
  190.   'set fields 73';
  191.   'set action.enter macro iwzmsqs.lx';
  192.   'set action.end macro iwzmusq.lx end';
  193.   'extract synonym.find into synfind';
  194.   'set global.iwzmusq_synfind_'docnum synfind;
  195.   'set synonym.find macro iwzmusq.lx find';
  196.   end;
  197. else
  198.   do;
  199.   'set menucheck.'menunum 'OFF';
  200.   'set menuactive.'menunump 'OFF';
  201.   'set fields';
  202.   'set action.enter SPLITLINE';
  203.   'set action.end';
  204.   'extract global.iwzmusq_synfind_'docnum 'into synfind';
  205.   'set synonym.find' synfind;
  206.   end;
  207. call traceit 1 'Normal exit';
  208. exit 0;
  209. Get_MVSINFO:
  210. Procedure expose env cobolroot mvsinfo. whoami tempdir trace
  211.  
  212. rtn = 0
  213. null = '0000'x
  214. crlf = '0D0A'x
  215. mvsinfo. = ''
  216. mvsinfoQ = translate('iwzm_MVSINFO.DAT_YALE');
  217.  
  218. oldq = rxqueue('Set',mvsinfoQ)   /* switch to mvsinfo queue */
  219. if queued() = 0 then do                   /* if Q is missing we'll */
  220.   qname = rxqueue('Create',mvsinfoQ)      /* create it and put a bad */
  221.   if qname = mvsinfoQ then push 'Sven'    /* timestamp on it, else */
  222.   else x=rxqueue('Delete',qname)          /* it was in use (we hope) */
  223.   end                                     /* so we'll assume we can */
  224. parse pull mvsstuff; push mvsstuff        /* get/replace Q contents */
  225. parse value mvsstuff with ts (null) . cobolroot (null) mvsstuff /* get */
  226.                                         /* timestamp and cobolroot */
  227. if ts <> 'Sven' then do;
  228.   mvsinfo = cobolroot'\MACROS\MVSINFO.DAT'
  229.   bad_mvsinfo = '    **' whoami '****'crlf'    **error*' mvsinfo,
  230.                 'is unavailable, missing or empty **'
  231.  
  232.   x=SysFileTree(mvsinfo,'ts','F')       /* get MVSINFO.DAT's timestamp */
  233.   if ts.0 <> 1 then do
  234.     say bad_mvsinfo
  235.     return 12;
  236.     end
  237.   parse var ts.1 v0 v1 v2 .
  238.   timestamp ='mvsinfo.dat.timestamp' v0 v1 v2
  239.   end;
  240. else
  241.   timestamp = 'Yale'
  242. if timestamp <> ts then do              /* timestamps match? */
  243.   pull mvsstuff                         /* no, remove bad contents */
  244.   rtn = "iwzmIR.CMD"()                /* ask for new stuff */
  245.   if rtn = 0 then do
  246.     parse pull mvsstuff; push mvsstuff    /* get/replace Q contents */
  247.                                         /* remove timestamp and     */
  248.                                         /* cobolroot                */
  249.     parse value mvsstuff with . (null) . cobolroot ( null) mvsstuff
  250.     end
  251.   end
  252. qname = rxqueue('Set',oldq)      /* restore normal queue */
  253.  
  254. do while (mvsstuff<>'') & (rtn=0)   /* mvsinfo. structure */
  255.   parse value mvsstuff with key val (null) mvsstuff
  256.   if mvsinfo.key = '' then do       /* e.g. mvsinfo.TYPE='' */
  257.     mvsinfo.KEYS = mvsinfo.KEYS key /* no substitution for KEYS */
  258.     mvsinfo.key.1 = val             /* e.g. mvsinfo.TYPE.1=val  */
  259.     mvsinfo.key = 1                 /* e.g. mvsinfo.TYPE=1      */
  260.     end
  261.   else do
  262.     x = mvsinfo.key + 1             /* e.g. mvsinfo.TYPE+1     */
  263.     mvsinfo.key.x = val             /* e.g. mvsinfo.TYPE.2=val */
  264.     mvsinfo.key = x                 /* e.g. mvsinfo.TYPE=2     */
  265.     end
  266.   end
  267.  
  268. return rtn
  269.  
  270. Set_MVSINFO_Vars:
  271.  
  272.  parse var mvsinfo.CLOSECMD.1 closecmd;
  273.  parse var mvsinfo.CLOSEFILE.1 closefile;
  274.  parse var mvsinfo.FILESYS.1 filesys accessmon testaccess;
  275.  parse var mvsinfo.FSSTARTCMD.1 fsstartcmd;
  276.  parse var mvsinfo.FSSTOPCMD.1 fsstopcmd;
  277.  parse var mvsinfo.HEADER.1 header;
  278.  parse var mvsinfo.JOBLOG.1 joblog;
  279.  parse var mvsinfo.MAXCMD.1 maxcmd;
  280.  parse var mvsinfo.LANGUAGE.1 language;
  281.  parse var mvsinfo.MOUNTCMD.1 mountcmd;
  282.  parse var mvsinfo.MVSCOMM.1 mvscomm;
  283.  parse var mvsinfo.iwzmEDT.1 iwzmedt;
  284.  parse var mvsinfo.NFS.1 nfs;
  285.  parse var mvsinfo.NULLSTDIN.1 nullstdin;
  286.  parse var mvsinfo.OUTSHOW.1 outshow;
  287.  parse var mvsinfo.PROTSAVE.1 protsave tempmult;
  288.  parse var mvsinfo.PWD.1 pwd pwdasis pwdt pwde;
  289.  parse var mvsinfo.READTIMEOUT.1 readtimeout;
  290.  parse var mvsinfo.REXECCMD.1 rexeccmd;
  291.  parse var mvsinfo.SDU.1 sdu;
  292.  parse var mvsinfo.SIGYCLST.1 sigyclst;
  293.  parse var mvsinfo.SYSPROC.1 sysproc;
  294.  parse var mvsinfo.SYSTEM.1 system;
  295.  parse var mvsinfo.TEMPDRIVE.1 tempdrive;
  296.  parse var mvsinfo.TEMPDATA.1 tempdata;
  297.  parse var mvsinfo.TESTFILE.1 testfile;
  298.  parse var mvsinfo.TRACE.1 trace tracekeep;
  299.  parse var mvsinfo.TRACECMD.1 tracecmd;
  300.  parse var mvsinfo.TRACEMOD.1 tracemod;
  301.  parse var mvsinfo.UMOUNTCMD.1 umountcmd;
  302.  parse var mvsinfo.USERID.1 userid;
  303.  parse var mvsinfo.WORKSYS.1 worksys;
  304.  parse var mvsinfo.WRITETIMEOUT.1 writetimeout;
  305.  
  306.  parse var mvsinfo.DRIVE numdrive;
  307.  if numdrive = '' then
  308.    numdrive = 0;
  309.  do ii = 1 to numdrive;
  310.    parse var mvsinfo.DRIVE.ii,
  311.              drive.ii highqual.ii trans.ii mapping.ii sidefile.ii;
  312.    end;
  313.  
  314.  parse var mvsinfo.TYPE numtype;
  315.  if numtype = '' then
  316.    numtype = 0;
  317.  do ii = 1 to numtype;
  318.    parse var mvsinfo.TYPE.ii type.ii ext.ii;
  319.    end;
  320.  
  321. return
  322.  
  323. /* */
  324. Traceit:
  325.  parse arg iwz_trc_level iwz_trc_message;
  326.  if iwz_trc_level > trace then
  327.    return;
  328.  if pwd <> '********' & pwd <> '++++++++' & pwd <> '========' then
  329.    do;
  330.    do forever;
  331.      if pos(pwd,iwz_trc_message) = 0 then
  332.        leave;
  333.      parse var iwz_trc_message iwz_trc_message1 (pwd) iwz_trc_message2;
  334.      iwz_trc_message = iwz_trc_message1||'********'||iwz_trc_message2
  335.      end;
  336.    end
  337.  iwz_trc_message = date('O') time('L') whoami':' iwz_trc_message;
  338.  xx = lineout(tempdir'\iwzmTRC.TRC',iwz_trc_message);
  339.  xx = stream(tempdir'\iwzmTRC.TRC','C','CLOSE');
  340.  if tracecmd <> '' then
  341.    interpret tracecmd;
  342. return;
  343.  
  344. /* */
  345. sayit:
  346.  parse arg iwz_sayit_arg;
  347.  if trace > 2 then
  348.    call traceit 3 '--->' iwz_sayit_arg;
  349.  say iwz_sayit_arg;
  350. return;
  351. /*
  352. :runit
  353. @rexx %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
  354. @rem */
  355.