/* IBM Personal/370 (c) Copyright IBM Corporation 1993               11/29/93 */

trace n;
address command;

Call save_set /* Save MSG, WNG, EMSG, etc. settings     */

/* Have to turn off messages, etc. to stop interference */
/* with full screen mode...                             */
/* If wakeup is available, use it to save msgs for      */
/* later display, otherwise, just turn them off.        */
/* WARNING messages could also be turned off, but we    */
/* leave them on since they are rare and may be warning */
/* the user the system is going down.  The installation */
/* can alter this if they want.                         */
'WAKEUP +0 (IUCVMSG'
if rc=2 | RC=5
   then do;
            wake=1;
            'CP SET IMSG IUCV';
        /*  'CP SET WNG  IUCV'; */
        end;
   else do;
            wake=0;
            'CP SET MSG  OFF';
            'CP SET IMSG OFF';  /* avoid CP TRANSFER msgs */
        /*  'CP SET WNG  OFF'; */
        end;
'CP SET ACNT OFF';
'   SET BLIP OFF';
'CP SET EMSG ON';   /* must be ON for correct workstation prefixes */

'EXEC CMSSERV'                 /* invoke the server */
src=rc;

/* display any messages that might have come in while we were running */
if wake
   then do;
             'MAKEBUF';
             do i=1;
                'WAKEUP +0 (IUCVMSG QUIET';
                if rc<>5 then leave;
                if i=1
                   then say 'Messages received while running AWSHOST:'
                parse pull wid msg
                say msg;
             end;
             'WAKEUP RESET';
             'DROPBUF';
        end;

Call reset;  /* Restore EMSG, etc. back the way it was... */

If src = 801 then do
   Say 'The CMSSERV EXEC was not found.  Contact your System Programmer.'
   End

exit src;
/*--------------------------------------------------------------------*/
SAVE_SET:
  procedure expose cpset. cmsset.
  cpset.='';
  cmsset.='';
  Save_options='MSG WNG EMSG ACNT RUN LINEDIT TIMER ASSIST IMSG' ,
               'VMCONIO CPCONIO';
  'MAKEBUF';
  n=queued();
  'EXECIO * CP (STRING QUERY SET';
  n=queued()-n;
  j=1;
  do i=1 to n;
     pull stuff;
     stuff = stuff ','
     do while(stuff/='');
        parse var stuff option value ',' stuff;
        if find(save_options,option)>0
           then do;
                  cpset.j = option value
                  j=j+1;
                end;
     end;
  end;
  cpset.0=j-1;  /* number of CP items that have been saved */
  address cms 'QUERY BLIP (STACK';
  pull . '=' value;
  cmsset.1 = 'BLIP' value
  cmsset.0 =1;
  'DROPBUF';
return;

Reset:procedure expose cpset. cmsset.;
  parse var cp_set option value ',' stuff;
  do i=1 to cpset.0;
     'EXECIO 0 CP (STRING SET' cpset.i;
  end;

  if trace()='O' | trace()='N' then 'SET CMSTYPE HT';
  do i=1 to cmsset.0;
     address CMS 'SET' cmsset.i;
  end;
  'SET CMSTYPE RT';
return;
