home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / db22fr.zip / SQLUEXIT.CMD < prev   
OS/2 REXX Batch file  |  1993-05-12  |  25KB  |  751 lines

  1. /*
  2.  ┌──────────────────────────────────────────────────────────────────┐
  3.  │                                                                  │
  4.  │  Name       : SQLUEXIT.cmd                                       │
  5.  │  Purpose    : A customized DBM SQLUEXIT program                  │
  6.  │               that is purposely simplified for demos,            │
  7.  │               simple testing, and learning.                      │
  8.  │  Platform   : DB2/2 and OS/2 2.1                                 │
  9.  │  Author     : Jeff Fisher                                        │
  10.  │               Copyright, IBM Corporation 1993                    │
  11.  │               Toronto OS/2 Planning                              │
  12.  │  Written    : 08/31/91                                           │
  13.  │                                                                  │
  14.  │  Ideas      : - better audit report                              │
  15.  │               - timings for perf testing                         │
  16.  │                                                                  │
  17.  └──────────────────────────────────────────────────────────────────┘
  18. */
  19. signal on syntax
  20.  
  21. MAIN:
  22. /*
  23.  ┌──────────────────────────────────────────────────────────────────┐
  24.  │  Procedure: MAIN                                                 │
  25.  │     Validate and branch by parms received                        │
  26.  │     Archive/Retreive and Backup/Restore receive different parms  │
  27.  │      and are thus handled differently                            │
  28.  │      for the displayed messages and audit log                    │
  29.  └──────────────────────────────────────────────────────────────────┘
  30. */
  31.     call SetUp
  32.  
  33.     parse upper arg ParmOpt Parm1 Parm2 Parm3 Parm4 Parm5
  34.  
  35.     call EditParms
  36.  
  37.     SELECT
  38.        WHEN ParmOpt = 'ARCHIVE' | ParmOpt = 'RETRIEVE' then
  39.            do
  40.                call HandleParms1
  41.                if ParmOpt = 'ARCHIVE'  then signal LogArchive
  42.                if ParmOpt = 'RETRIEVE' then signal LogRetrieve
  43.            end
  44.        WHEN ParmOpt = 'BACKUP' | ParmOpt = 'RESTORE' then
  45.            do
  46.                call HandleParms2
  47.                if ParmOpt = 'BACKUP'  then signal DBBackup
  48.                if ParmOpt = 'RESTORE' then signal DBRestore
  49.            end
  50.        OTHERWISE
  51.           do
  52.               say c.itred 'Invalid option passed from the DBM'
  53.               sqluexitrc = UEXIT.PARM;
  54.               signal Exit_Control
  55.           End
  56.     END
  57.  
  58.  
  59.  
  60. EditParms:
  61. /*
  62.  ┌──────────────────────────────────────────────────────────────────┐
  63.  │  Procedure: edit all five parms                                  │
  64.  │   (conditional on parm type too)                                 │
  65.  └──────────────────────────────────────────────────────────────────┘
  66. */
  67.  
  68.     Parm1   = strip(Parm1)
  69.     if Parm1 = '' then do
  70.        say c.itred 'Parm1 is null'
  71.        sqluexitrc = UEXIT.PARM
  72.        signal Exit_Control
  73.     end
  74.  
  75.     Parm2   = strip(Parm2)
  76.     if Parm2 = '' then do
  77.        say c.itred 'Parm2 is null'
  78.        sqluexitrc = UEXIT.PARM
  79.        signal Exit_Control
  80.     end
  81.  
  82.     Parm3   = strip(Parm3)
  83.     if Parm3 = '' then do
  84.        say c.itred 'Parm3 is null'
  85.        sqluexitrc = UEXIT.PARM
  86.        signal Exit_Control
  87.     end
  88.  
  89.     Parm4   = strip(Parm4)
  90.     if Parm4 = '' then do
  91.        say c.itred 'Parm4 is null'
  92.        sqluexitrc = UEXIT.PARM
  93.        signal Exit_Control
  94.     end
  95.  
  96.     If ParmOpt = 'BACKUP' | ParmOpt = 'RESTORE' then
  97.         do
  98.             Parm5   = strip(Parm5)
  99.             if Parm5 = '' then do
  100.                say c.itred 'Parm5 is null'
  101.                sqluexitrc = UEXIT.PARM
  102.                signal Exit_Control
  103.             end
  104.         end
  105.     Else
  106.         FullPath = Parm3||Parm4;
  107.  
  108.     return
  109.  
  110.  
  111.  
  112. HandleParms1:
  113. /*
  114.  ┌──────────────────────────────────────────────────────────────────┐
  115.  │  Procedure: handle parms for Archive/Retrieve                    │
  116.  │                                                                  │
  117.  │   Display a message and write parms to audit file                │
  118.  └──────────────────────────────────────────────────────────────────┘
  119. */
  120. /*
  121.  ┌───────────────────────────────────────────────────────┐
  122.  │  display and log all parms                            │
  123.  └───────────────────────────────────────────────────────┘
  124. */
  125.     say
  126.     say c.itgreen   '******************************************'
  127.     say c.itmagenta '   SQLUEXIT:' c.itcyan ParmOpt
  128.     say c.yellow    '     Date:' RunDate ' Time:' RunTime
  129.     say c.yellow    ' '
  130.     say c.yellow    '   Database Name  :'c.itcyan Parm2
  131.     say c.yellow    '           Drive  :'c.itcyan Parm1
  132.     say c.yellow    '   Log Path       :'c.itcyan Parm3
  133.     say c.yellow    '       Name       :'c.itcyan Parm4
  134.     say c.yellow    ' '
  135.     say c.yellow    '   Message Log    :'c.itcyan MessageLog
  136.     say c.itgreen   '******************************************'
  137.  
  138.     PT0 = '---------------------------------------------------------'
  139.     PT1 = '--> SQLUEXIT on 'RunDate' at 'RunTime
  140.     PT2 = '    Parameters received:'
  141.     PT3 = '        Action         :' ParmOpt
  142.     PT4 = '        Database Name  :' Parm2
  143.     PT5 = '                Drive  :' Parm1
  144.     PT6 = '        Log Path       :' Parm3
  145.     PT7 = '            Name       :' Parm4
  146.     CALL LINEOUT MessageLog,PT0
  147.     CALL LINEOUT MessageLog,PT1
  148.     CALL LINEOUT MessageLog,Space
  149.     CALL LINEOUT MessageLog,PT2
  150.     CALL LINEOUT MessageLog,PT3
  151.     CALL LINEOUT MessageLog,PT4
  152.     CALL LINEOUT MessageLog,PT5
  153.     CALL LINEOUT MessageLog,PT6
  154.     CALL LINEOUT MessageLog,PT7
  155.  
  156.     return
  157.  
  158.  
  159.  
  160. HandleParms2:
  161. /*
  162.  ┌──────────────────────────────────────────────────────────────────┐
  163.  │  Procedure: handle parms for Backup                              │
  164.  │                                                                  │
  165.  └──────────────────────────────────────────────────────────────────┘
  166. */
  167.  
  168.     DB_DRIVE  = strip(PARM1)
  169.     DB_NAME   = strip(PARM2)
  170.     RESP_FILE = strip(PARM3)
  171.     LABEL     = strip(PARM4)
  172.     REST_DIR  = strip(PARM4)
  173.     INSTANCE  = strip(PARM5)
  174.  
  175.     rsp_line = linein( RESP_FILE )       /* Get response file line */
  176.     call stream RESP_FILE, C, 'close'    /* Close response file */
  177.  
  178.     say
  179.     say c.itgreen   '******************************************'
  180.     say c.itmagenta '   SQLUEXIT:' c.itcyan ParmOpt
  181.     say c.yellow    '     Date:' RunDate ' Time:' RunTime
  182.     say c.yellow    ' '
  183.     say c.yellow    '   Instance       :'c.itcyan Parm5
  184.     say c.yellow    '   Database Name  :'c.itcyan Parm2
  185.     say c.yellow    '        Location  :'c.itcyan Parm1
  186.     say c.yellow    '   Response File  :'c.itcyan Parm3
  187.     say c.yellow    '        Response  :'c.itcyan rsp_line
  188.  
  189.     if ParmOpt = 'BACKUP' then
  190.         do
  191.             say c.yellow    '   Media Label    :'c.itcyan Parm4
  192.             PT9 = '        Media Label    :' Parm4
  193.         end
  194.     else
  195.         do
  196.             say c.yellow    '   Restore Dir    :'c.itcyan Parm4
  197.             PT9 = '        Restore Dir    :' Parm4
  198.         end
  199.  
  200.     say c.yellow    ' '
  201.     say c.yellow    '   Message Log    :'c.itcyan MessageLog
  202.     say c.itgreen   '******************************************'
  203.  
  204.     PT0 = '---------------------------------------------------------'
  205.     PT1 = '--> SQLUEXIT on 'RunDate' at 'RunTime
  206.     PT2 = '    Parameters received:'
  207.     PT3 = '        Action         :' ParmOpt
  208.     PT4 = '        Instance       :' Parm5
  209.     PT5 = '        Database Name  :' Parm2
  210.     PT6 = '                Drive  :' Parm1
  211.     PT7 = '        Response File  :' Parm3
  212.     PT8 = '             Response  :' rsp_line
  213.     CALL LINEOUT MessageLog,PT0
  214.     CALL LINEOUT MessageLog,PT1
  215.     CALL LINEOUT MessageLog,Space
  216.     CALL LINEOUT MessageLog,PT2
  217.     CALL LINEOUT MessageLog,PT3
  218.     CALL LINEOUT MessageLog,PT4
  219.     CALL LINEOUT MessageLog,PT5
  220.     CALL LINEOUT MessageLog,PT6
  221.     CALL LINEOUT MessageLog,PT7
  222.     CALL LINEOUT MessageLog,PT8
  223.     CALL LINEOUT MessageLog,PT9
  224.  
  225.     return
  226.  
  227.  
  228.  
  229. LogArchive:
  230. /*
  231.  ┌───────────────────────────────────────────────────────────────┐
  232.  │  Procedure: Log Archive                                       │
  233.  └───────────────────────────────────────────────────────────────┘
  234. */
  235.  
  236.     DB_DRIVE = left(strip(PARM1), 1)                  /* Throw away the colon */
  237.     DB_NAME  = strip(PARM2)
  238.     LOG_PATH = strip(PARM3)
  239.     LOG_FILE = strip(PARM4)
  240.  
  241.  
  242.     LOG_PATH = LOG_PATH||LOG_FILE               /* Modify LOG_PATH to contain */
  243.                                                 /*  the full log file name    */
  244.  
  245.     if stream(LOG_PATH, c, 'query exists') = '' then      /* Log file exists? */
  246.         do
  247.             ErrMsg = 'The file 'LOG_PATH' was assumed to be previously archived'
  248.             sqluexitrc = UEXIT.OK
  249.             signal Exit_Control
  250.         end
  251.  
  252.     ARCH_PATH = db_logs_bkp_dir
  253.  
  254.     say c.brown
  255.     address cmd 'XCOPY 'LOG_PATH' 'ARCH_PATH
  256.     call checkrc
  257.  
  258.     signal Exit_Control
  259.  
  260.  
  261.  
  262. LogRetrieve:
  263. /*
  264.  ┌──────────────────────────────────────────────────────────────────┐
  265.  │  Procedure: Log Retrieve                                         │
  266.  └──────────────────────────────────────────────────────────────────┘
  267. */
  268.  
  269.     DB_DRIVE = left(strip(PARM1), 1)                  /* Throw away the colon */
  270.     DB_NAME  = strip(PARM2)
  271.     LOG_PATH = strip(PARM3)
  272.     LOG_FILE = strip(PARM4)
  273.  
  274.     ARCH_PATH = db_logs_bkp_dir
  275.  
  276.     say c.brown
  277.     address cmd 'XCOPY 'ARCH_PATH'\'LOG_FILE' 'LOG_PATH
  278.     call checkrc
  279.  
  280.     signal Exit_Control
  281.  
  282.  
  283.  
  284. DBBackup:
  285. /*
  286.  ┌──────────────────────────────────────────────────────────────────┐
  287.  │  Procedure: DBBackup                                             │
  288.  │                                                                  │
  289.  └──────────────────────────────────────────────────────────────────┘
  290. */
  291. /*
  292.  ┌───────────────────────────────────────────────────────┐
  293.  │  On the first instance, erase the previous backup     │
  294.  │  (check for read-only files)                          │
  295.  └───────────────────────────────────────────────────────┘
  296. */
  297.   if INSTANCE = '1' then
  298.     do
  299.       say
  300.       address cmd 'ATTRIB 'db_files_bkp_dir'\*.* -r >NUL 2>NUL'
  301.       address cmd 'DEL 'db_files_bkp_dir' /N >NUL 2>NUL'
  302.     end
  303. /*
  304.  ┌───────────────────────────────────────────────────────┐
  305.  │  display an informative message                       │
  306.  └───────────────────────────────────────────────────────┘
  307. */
  308.   if INSTANCE = '1' then
  309.       say c.itgreen  '--> Backing up UIF file'
  310.   else
  311.       say c.itgreen  '--> Backing up database files'
  312. /*
  313.  ┌───────────────────────────────────────────────────────┐
  314.  │  xcopy files                                          │
  315.  │  db_files_bkp_dir was set in the configuration section │
  316.  │    of the SetUp procedure                             │
  317.  └───────────────────────────────────────────────────────┘
  318. */
  319.   say c.brown
  320.   address cmd 'XCOPY 'rsp_line' 'db_files_bkp_dir
  321.   call checkrc
  322. /*
  323.  ┌───────────────────────────────────────────────────────┐
  324.  │  go to the exit control procedure                     │
  325.  └───────────────────────────────────────────────────────┘
  326. */
  327.   signal Exit_Control
  328.  
  329.  
  330.  
  331. DBRestore:
  332. /*
  333.  ┌──────────────────────────────────────────────────────────────────┐
  334.  │  Procedure: DBRestore                                            │
  335.  └──────────────────────────────────────────────────────────────────┘
  336. */
  337. /*
  338.  ┌───────────────────────────────────────────────────────┐
  339.  │  display an informative message                       │
  340.  └───────────────────────────────────────────────────────┘
  341. */
  342.   if INSTANCE = '1' then
  343.       say c.itgreen  'Restoring --> UIF file'
  344.   else
  345.       say c.itgreen  'Restoring --> database files'
  346. /*
  347.  ┌───────────────────────────────────────────────────────┐
  348.  │  setup filelist                                       │
  349.  └───────────────────────────────────────────────────────┘
  350. */
  351.   parse value rsp_line with  . '\' . '\' filelist
  352. /*
  353.  ┌───────────────────────────────────────────────────────┐
  354.  │  xcopy files                                          │
  355.  │  restore dest came from ?                             │
  356.  │    of the SetUp procedure                             │
  357.  └───────────────────────────────────────────────────────┘
  358. */
  359.   say c.brown
  360.   address cmd 'XCOPY 'db_files_bkp_dir'\'filelist' 'DB_DRIVE||REST_DIR
  361.   call checkrc
  362. /*
  363.  ┌───────────────────────────────────────────────────────┐
  364.  │  go to the exit control procedure                     │
  365.  └───────────────────────────────────────────────────────┘
  366. */
  367.   signal Exit_Control
  368.  
  369.  
  370.  
  371. Verify_Path:
  372. /*
  373.  ┌──────────────────────────────────────────────────────────────────┐
  374.  │  Procedure: verify path                                          │
  375.  │     verifies paths                                               │
  376.  └──────────────────────────────────────────────────────────────────┘
  377. */
  378.     arg CHK_PATH
  379.  
  380.       curdir = directory()                           /* Save current directory  */
  381.  
  382.     /***************************************************************/
  383.     /* Separate drive from path and save the remainder of the path */
  384.     /***************************************************************/
  385.  
  386.       parse value CHK_PATH with drive '\' path_remain
  387.  
  388.     /*****************************************/
  389.     /* Break down path by subdirectory names */
  390.     /*****************************************/
  391.  
  392.       i = 1
  393.       do while path_remain <> ''
  394.         parse value path_remain with path.i '\' path_remain
  395.         i = i + 1                                    /* Subdirectory name index */
  396.       end
  397.  
  398.     /**********************************************************************/
  399.     /* Rebuild the path one subdirectory at a time checking to see if the */
  400.     /* path exist and, if not, create it.                                 */
  401.     /**********************************************************************/
  402.  
  403.       build_path = drive         /* Build path back up starting at drive letter */
  404.  
  405.       j = 1
  406.       do while j < i
  407.         build_path = build_path'\'path.j          /* Add a subdirectory to path */
  408.  
  409.         newdir = directory( build_path )       /* See if the path already exist */
  410.         if( newdir <> build_path ) then do
  411.           md_var = 'MKDIR 'build_path
  412.           address CMD md_var                     /* Let OS/2 make the directory */
  413.           if (rc <> 0) then do
  414.             ErrMsg = md_var'  *** FAILED, <'rc'>'
  415.             sqluexitrc = UEXIT.UNKNOWN
  416.             signal Exit_Control
  417.           end
  418.         end
  419.  
  420.         j = j + 1                               /* Bump subdirectory name index */
  421.       end
  422.  
  423.       call directory curdir                 /* Return to the original directory */
  424.  
  425.     return 0
  426.  
  427.  
  428. checkrc:
  429. /*
  430.  ┌──────────────────────────────────────────────────────────────────┐
  431.  │  Procedure: check OS/2 return codes                              │
  432.  │     called from XCOPY and other OS/2 commands                    │
  433.  │     and set sqluexitrc                                           │
  434.  └──────────────────────────────────────────────────────────────────┘
  435. */
  436.    os2_rc = rc
  437.    SELECT
  438.        WHEN os2_rc = 0 then
  439.            do
  440.              sqluexitrc = UEXIT.OK;
  441.              return;
  442.            end
  443.        WHEN os2_rc = 1 then
  444.            do
  445.              ErrMsg= 'OS/2 XCOPY ERROR <1>: No files found to Backup or Restore'
  446.              sqluexitrc = UEXIT.NOTFOUND;
  447.              return;
  448.            end
  449.        WHEN os2_rc = 2 then
  450.            do
  451.              ErrMsg= 'OS/2 XCOPY ERROR <2>: Busy files not Backed up or Restored'
  452.              sqluexitrc = UEXIT.UNKNOWN;
  453.              return;
  454.            end
  455.        WHEN os2_rc = 3 then
  456.            do
  457.              ErrMsg= 'OS/2 XCOPY ERROR <3>: Command Terminated by user'
  458.              sqluexitrc = UEXIT.OPCAN;
  459.              return;
  460.            end
  461.        WHEN os2_rc = 4 then
  462.            do
  463.              ErrMsg= 'OS/2 XCOPY ERROR <4>: Command Terminated due to error'
  464.              sqluexitrc = UEXIT.UNKNOWN;
  465.              return;
  466.            end
  467.        OTHERWISE                                               /* Unknown error */
  468.            do
  469.              ErrMsg= 'OS/2 XCOPY command returned ERROR <'os2_rc'>'
  470.              sqluexitrc = UEXIT.UNKNOWN;
  471.              return;
  472.            end
  473.    END
  474.  
  475.   return
  476.  
  477.  
  478. SetUp:
  479. /*
  480.  ┌──────────────────────────────────────────────────────────────────┐
  481.  │  SetUp                                                           │
  482.  │     sets up variables and other etc.                             │
  483.  └──────────────────────────────────────────────────────────────────┘
  484. */
  485.     address cmd '@ECHO OFF'
  486.     call SetColor
  487. /*
  488.  ┌───────────────────────────────────────────────────────┐
  489.  │  sound beep signifying beginning                      │
  490.  └───────────────────────────────────────────────────────┘
  491. */
  492.     note.3 = 524
  493.     note.2 = 494
  494.     note.1 = 440
  495.     do i=1 to 3
  496.         call beep note.i,50
  497.     end
  498.  
  499.     Space     = ' '
  500.     quote     = '"'
  501.     RunDate   = DATE()
  502.     RunTime   = TIME()
  503.     DT        = '*** 'RunDate', 'RunTime
  504.  
  505. /*
  506.  ┌──────────────────────────────────────────────────────┐
  507.  │  This user exit can only handle 1 database           │
  508.  │    and does not handle archiving old backups         │
  509.  │                                                      │
  510.  │  db_name            the name of the database         │
  511.  │                                                      │
  512.  └──────────────────────────────────────────────────────┘
  513. */
  514.     db_name      = 'frdemo'
  515.  
  516. /*
  517.  ┌──────────────────────────────────────────────────────┐
  518.  │ Location of the backed-up DBs and LOGs               │
  519.  │                                                      │
  520.  │  db_files_bkp_dir   where to put the backup          │
  521.  │  db_logs_bkp_dir    temp hold location for logs      │
  522.  │                                                      │
  523.  │  call VERIFY_DIR to make these if they don't         │
  524.  │    already exist                                     │
  525.  └──────────────────────────────────────────────────────┘
  526. */
  527.     db_files_bkp_dir  = 'D:\frdemo.bkp\database'
  528.     db_logs_bkp_dir   = 'D:\frdemo.bkp\logs'
  529.  
  530.     call Verify_Path(db_files_bkp_dir)
  531.     VERIFY_DIR = 'TRUE'
  532.     call Verify_Path(db_logs_bkp_dir)
  533.     VERIFY_DIR = 'TRUE'
  534.  
  535.     ARCH_PATH = ''
  536.  
  537. /*
  538.  ┌───────────────────────────────────────────────────────┐
  539.  │  Make sure the directory exists                       │
  540.  │                                                       │
  541.  │  EXITDIR          the prefix of many following files  │
  542.  └───────────────────────────────────────────────────────┘
  543. */
  544.     EXITDIR = 'D:\SQLUEXIT'
  545.  
  546.     call Verify_Path(EXITDIR)      /* Path exists?/If not, create it */
  547.     VERIFY_DIR = 'TRUE'
  548.  
  549. /*
  550.  ┌───────────────────────────────────────────────────────┐
  551.  │  Log handling                                         │
  552.  │                                                       │
  553.  │    MessageLog     actual name of the audit file       │
  554.  │    ErrMsg         field containing a message string   │
  555.  │    AUDIT          user configurable parm, whether     │
  556.  │                     or not to create an audit trail   │
  557.  └───────────────────────────────────────────────────────┘
  558. */
  559.     MessageLog = 'D:\frdemo.bkp\audit.log'
  560.     AUDIT       = 'Y'
  561.     ErrMsg = ''
  562.  
  563. /*
  564.  ┌────────────────────────────────────┐
  565.  │ Successful                         │
  566.  └────────────────────────────────────┘
  567. */
  568.     UEXIT.OK       = 0;
  569.  
  570. /*
  571.  ┌────────────────────────────────────┐
  572.  │ Unsuccessful - retry in 5 minutes  │
  573.  └────────────────────────────────────┘
  574. */
  575.     UEXIT.RES      = 4;           /* temporary resource error        */
  576.     UEXIT.OPATTN   = 8;           /* operator intervention required  */
  577.  
  578. /*
  579.  ┌────────────────────────────────────┐
  580.  │ Unsuccessful - can't retry         │
  581.  └────────────────────────────────────┘
  582. */
  583.     UEXIT.HARDWARE = 12;          /* hardware error                  */
  584.     UEXIT.DEFECT   = 16;          /* error in uexit/function called  */
  585.     UEXIT.PARM     = 20;          /* error in passed parameter       */
  586.     UEXIT.NOTFOUND = 24;          /* restore file couldn't be found  */
  587.     UEXIT.UNKNOWN  = 28;          /* i/o or opsys failure            */
  588.     UEXIT.OPCAN    = 32;          /* uexit terminated by the user    */
  589.  
  590.     sqluexitrc = UEXIT.OK;        /* USED TO PASS BACK RETURN CODE   */
  591.  
  592.     return 0
  593.  
  594.  
  595.  
  596. Exit_Control:
  597. /*
  598.  ┌──────────────────────────────────────────────────────────────────┐
  599.  │  Procedure: branch by sqluexitrc                                 │
  600.  └──────────────────────────────────────────────────────────────────┘
  601. */
  602.     if sqluexitrc = UEXIT.OK then
  603.         signal Exit_Ok
  604.     else
  605.         signal Exit_Error
  606.  
  607.  
  608.  
  609. Exit_Error:
  610. /*
  611.  ┌──────────────────────────────────────────────────────────────────┐
  612.  │  Procedure: Exit_Error                                           │
  613.  │     fatal exit                                                   │
  614.  └──────────────────────────────────────────────────────────────────┘
  615. */
  616.     call beep 200,500
  617.  
  618.     err1 = '--> SQLUEXIT: error taken on 'RunDate' @ 'RunTime;
  619.     err2 = '    Error code being returned to DBM:' sqluexitrc
  620.     err3 = '    Parms received:'
  621.     err4 = '    Error Message:'
  622.  
  623.     say
  624.     say c.itred err1
  625.     say c.itred err2
  626.     say c.itred err3
  627.     say c.itred parmopt
  628.     say c.itred parm1
  629.     say c.itred parm2
  630.     say c.itred parm3
  631.     say c.itred parm4
  632.     say c.itred parm5
  633.     say c.itred err4
  634.     say c.itred ErrMsg
  635.  
  636.     pause
  637.  
  638.     CALL LINEOUT MessageLog,space
  639.     CALL LINEOUT MessageLog,err2
  640.     CALL LINEOUT MessageLog,err1
  641.     CALL LINEOUT MessageLog,err3
  642.     CALL LINEOUT MessageLog,parmopt
  643.     CALL LINEOUT MessageLog,parm1
  644.     CALL LINEOUT MessageLog,parm2
  645.     CALL LINEOUT MessageLog,parm3
  646.     CALL LINEOUT MessageLog,parm4
  647.     CALL LINEOUT MessageLog,parm5
  648.     CALL LINEOUT MessageLog,err4
  649.     CALL LINEOUT MessageLog,ErrMsg
  650.  
  651.     say c.normal
  652.  
  653.  
  654.     exit sqluexitrc;
  655.  
  656.  
  657. Exit_Ok:
  658. /*
  659.  ┌──────────────────────────────────────────────────────────────────┐
  660.  │  Procedure: Exit_Ok                                              │
  661.  │     good exit                                                    │
  662.  └──────────────────────────────────────────────────────────────────┘
  663. */
  664.     note.1 = 524
  665.     note.2 = 494
  666.     note.3 = 440
  667.     do i=1 to 3
  668.         call beep note.i,50
  669.     end
  670.  
  671.     ok1 =  '--> Exit returning, successful'
  672.     CALL LINEOUT MessageLog,space
  673.     CALL LINEOUT MessageLog,ok1
  674.     say c.itmagenta ok1
  675.  
  676.     say c.normal
  677.  
  678.  
  679.     exit UEXIT.OK
  680.  
  681.  
  682. SetColor:
  683. /*
  684.  ┌──────────────────────────────────────────────────────────────────┐
  685.  │  Procedure: SetColor                                             │
  686.  │     set up colors for screen display                             │
  687.  └──────────────────────────────────────────────────────────────────┘
  688. */
  689.     ansii.esc      = '1B'x
  690.     c.normal       = ansii.esc || '[0m'
  691.     c.highlite     = ansii.esc || '[1m'
  692.     c.blink        = ansii.esc || '[5m'
  693.     c.blackback    = ansii.esc || '[40m'
  694.     c.itredback    = ansii.esc || '[41m'
  695.     c.greenback    = ansii.esc || '[42m'
  696.     c.brownback    = ansii.esc || '[43m'
  697.     c.blueback     = ansii.esc || '[44m'
  698.     c.magentaback  = ansii.esc || '[45m'
  699.     c.cyanback     = ansii.esc || '[46m'
  700.     c.greyback     = ansii.esc || '[47m'
  701.     c.black        = c.normal || ansii.esc || '[30m'
  702.     c.red          = c.normal || ansii.esc || '[31m'
  703.     c.green        = c.normal || ansii.esc || '[32m'
  704.     c.brown        = c.normal || ansii.esc || '[33m'
  705.     c.blue         = c.normal || ansii.esc || '[34m'
  706.     c.magenta      = c.normal || ansii.esc || '[35m'
  707.     c.cyan         = c.normal || ansii.esc || '[36m'
  708.     c.grey         = c.normal || ansii.esc || '[37m'
  709.     c.itblack      = c.highlite || c.black
  710.     c.itred        = c.highlite || ansii.esc || '[31m'
  711.     c.itgreen      = c.highlite || ansii.esc || '[32m'
  712.     c.yellow       = c.highlite || ansii.esc || '[33m'
  713.     c.itblue       = c.highlite || ansii.esc || '[34m'
  714.     c.itmagenta    = c.highlite || ansii.esc || '[35m'
  715.     c.itcyan       = c.highlite || ansii.esc || '[36m'
  716.     c.white        = c.highlite || ansii.esc || '[37m'
  717.     c.std          = c.normal || c.itcyan || c.blackback
  718.     c.reset        = c.normal || c.grey || c.blackback
  719.     return 0
  720.  
  721.  
  722. syntax:
  723.     Syn1 = 'syntax error in the rexx program'
  724.     CALL LINEOUT MessageLog,Syn1
  725.     CALL LINEOUT MessageLog,sigl
  726.  
  727.     say c.itred syn1
  728.     say c.itred sigl
  729.     pause
  730.  
  731.     say 'rexx error' rc 'in line' sigl':' errortext(rc)
  732.     pause
  733.     say sourcall(sigl)
  734.     pause
  735.     pause
  736.     return
  737.  
  738.  
  739.  
  740. HALT:
  741. /*
  742.  ┌──────────────────────────────────────────────────────────────────┐
  743.  │  Procedure: Halt                                                 │
  744.  │     called when a ctrl-c is received                             │
  745.  └──────────────────────────────────────────────────────────────────┘
  746. */
  747.     ErrMsg = 'user terminated with a ctrl-c'
  748.     sqluexitrc=UEXIT.OPCAN
  749.     pause
  750.     signal Exit_Control
  751.