#! ./srexx

/*
 * setup:  SEDIT and S/REXX setup script. Do not modify it.
 *
 *   Copyright (C) 1991-1996 by Benaroya et Compagnie
 *   All rights reserved.
 */

signal on novalue
option setenv mixed noload
address csh

parse arg a

say ''
if a = 'auto' then
 { say 'This is the initial SEDIT-S/REXX setup. It has been called'
   say 'automatically by install. In the future, you may use it again by typing:'
   say ''
   say '  % 'cwd()'/setup'
   say ''
 }
else say

sayn 'Do you want to customize SEDIT (Y/N): '
if get_rep() then call setup_sedit

say ''
sayn 'Do you want to customize S/REXX (Y/N): '
if get_rep() then call setup_srexx

exit 0

setup_sedit:

new = '.sedit_std'
if ~state('profile'new) then
 { say
   say 'setup: ... Saving the original configuration files.'
   sayx 'cp profile.sedit profile'new
   sayx 'cp prof_pdf.sedit prof_pdf'new
   sayx 'cp prof_xedit.sedit prof_xedit'new
   sayx 'cp .srexxrc .srexxrc_std'
   sayx 'cp sedit.srexxrc sedit.srexxrc_std'
 }

say
say '         ------------- Starting SEDIT SETUP -------------'
say
say  'If you are an MVS/PDF user, you may skip this section.'
sayn 'Do you want to customize the CMS/XEDIT like SEDIT facilities ? (Y/N) '
if get_rep() then call cust_set_xedit
say
sayn 'Will you be using SEDIT in MVS/PDF mode ? (Y/N) '
if get_rep() then
 { say 'You may use SEDIT with the following commands:'
   say
   say '   % 'cwd()'/psedit'
   say
   say 'or:'
   say
   say '   % 'cwd()'/pdf'
   say
   say 'The "pdf" command is the closest to PDF, but by using it, you will'
   say 'lose some useful workstation features, such as the cut and paste'
   say 'function keys. "pdf" is useful if you do not have the time to learn'
   say 'SEDIT specific features, and want to start working with a familiar'
   say 'environment.'
   say '"pdf" can be customized by creating a "~/pdfprof.sedit" profile macro'
   say 'from scratch.'
   say
   say '"psedit" can be customized by each user by copying and modifying'
   say 'the "'cwd()'/profile.sedit" file into their personal home directory.'
   call pause
 }
else say
say 'By default, SEDIT displays a bright background, and uses black characters.'
say 'You may want to display green characters on a black background, to get'
say 'a full "3270" look and feel by changing the "COLOR_MODEL = ''standard''"'
say 'statement in the various profile files with the'
say '"COLOR_MODEL = ''reverse''" statement.'
say
sayn 'Do you want me to change the color model? (Y/N) '
if get_rep() then
 { trace off
   say
   call ch_col './profile.sedit'
   call ch_col './prof_pdf.sedit'
   call ch_col './prof_xedit.sedit'
 }
say
say '          ------------- Ending SEDIT SETUP -------------'
say

return



setup_srexx:

say
say '         ------------- Starting S/REXX SETUP -------------'
say
say 'S/REXX features 2 main differences when compared with the standard'
say 'IBM REXX.'
say
say '1) The default TRACE setting is "TRACE OFF" instead of "TRACE N".'
say '   This setting has been chosen because UNIX commands seldom'
say '   return a negative error code.'
say '   You can override this setting by adding a "TRACE N" statement in the'
say '   'cwd()'/.srexxrc and 'cwd()'/sedit.srexxrc files.'
say
sayn 'Do you want me to do so ? (Y/N) '
if get_rep() then
 { 'execio 1 diski .srexxrc . . '1+lines('.srexxrc')'(finis string TRACE N'
   'execio 1 diski sedit.srexxrc . . '1+lines('sedit.srexxrc')'(finis string TRACE N'
   say
   say ' ******* The "TRACE N" statement has been added.'
 }
say
say '2) S/REXX is able to dynamically load external routines. This permits'
say '   programs to share REXX variables with external subprograms. '
say '   Please read the S/REXX user''s guide for more information about this'
say '   facility.'
say '   Using EXIT inside a dynamically loaded procedure is the same as using'
say '   EXIT within an internal procedure: the current REXX program is'
say '   terminated.'
say '   This behavior may cause some mainframe macros to stop working, where'
say '   an EXIT statement in an external routine terminates only that routine.'
say '   Adding "OPTION NOLOAD" in the 'cwd()'/.srexxrc and'
say '   'cwd()'/sedit.srexxrc files will disable dynamic loading.'
say
sayn 'Do you want me to do so ? (Y/N) '
if get_rep() then
 { 'execio 1 diski .srexxrc . . '1+lines('.srexxrc')'(finis string OPTION NOLOAD'
   'execio 1 diski sedit.srexxrc . . '1+lines('sedit.srexxrc')'(finis string OPTION NOLOAD'
   say
   say ' ******* The "OPTION NOLOAD" statement has been added.'
 }
say
say '          ------------- Ending S/REXX SETUP -------------'
say

return

cust_set_xedit:

say
say 'You may use SEDIT with the following commands:'
say
say '   % 'cwd()'/sedit'
say
say 'or:'
say
say '   % 'cwd()'/xedit'
say
say 'The "xedit" command is the closest to XEDIT, but by using it, you will'
say 'lose some useful workstation features, such as the cut and paste'
say 'function keys. "xedit" is useful if you do not have the time to learn'
say 'SEDIT specific features, and want to start working with a familiar'
say 'environment.'
say '"xedit" can be customized by creating a "~/xeditprof.sedit" profile macro'
say 'from scratch.'
say
say 'The purpose of this script is to customize the "sedit" command, by'
say 'altering the "'cwd()'/profile.sedit" file. Further and personal'
say 'customisation can be achieved by each user by copying and modifying'
say 'the "'cwd()'/profile.sedit" file into their personal home directory.'
call pause
say 'By default, "sedit" offers some statistical enhancements over the'
say 'XEDIT behavior. For example, we found out that most of the time, a user'
say 'using the CHANGE command wants to modify every occurrence of a string.'
say 'With XEDIT, you have to type, for example, "c/a/b/**" to do so. With'
say 'SEDIT, you have to type "c/a/b", because the CHANGE command changes all'
say 'the occurrences by default.'
say
say 'These kind of improvements may confuse experienced XEDIT users, and may'
say 'cause your current CMS macros to no longer work. To restore the XEDIT'
say 'general behavior, you need to add the "set_xedit" macro in your'
say '"'cwd()'/profile.sedit" file.'
say
sayn 'Do you want me to do add the "set_xedit" statement? '
if get_rep() then
 { trace off
   'execio * diskr ./profile.sedit . . 1(locate /set_xedit/ stem found.'
   trace e
   if rc = 0 then
    { parse var found.2 . line
      "execio 1 diskw ./profile.sedit . . "line"(finis string 'set_xedit' /* This is the $xhome/xmac/set_xedit.x macro */"
      say
      say ' *******  "set_xedit" has been added.'
      say
    }
   else
    { 'execio * diskr ./profile.sedit . . 1(locate /START of user modification/ stem found.'
      if rc = 0 then
       { parse var found.2 . line
         "execio 1 diski ./profile.sedit . . "line+1"(finis string 'set_xedit' /* This is the $xhome/xmac/set_xedit.x macro */"
         say
         say ' *******  "set_xedit" has been added.'
         say
       }
      else
       { say 'Sorry, the profile has been manually modified, and I cannot'
         say 'find by myself a place to insert the "set_xedit" statement.'
       }
    }

 }

return


pause:procedure

say
sayn 'Hit the "Enter" or "Return" key to continue.'
pull foo
say
say
return

get_rep:
  pull rep
  rep = strip(rep)
  say
  if rep[1] = 'Y' then return 1
return 0


ch_col:procedure
  parse arg name

  trace off
  'execio * diskr 'name' . . 1(locate /COLOR_MODEL =/ stem found.'
  if rc = 0 then
   { parse var found.2 . line
     'execio 1 diskw 'name' . . 'line'(finis string COLOR_MODEL = ''reverse''   /* ''standard'' */'
     say ' *******  COLOR_MODEL = ''reverse'' has been added in the 'name' file.'
   }
  else
   { say 'Sorry, the 'name' file has been manualy changed, and I cannot change'
     say 'the color model by myself.'
   }

 return
