home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 19 Printer / 19-Printer.zip / slpos2.zip / SLPOS2.CMD next >
OS/2 REXX Batch file  |  1996-11-11  |  23KB  |  593 lines

  1. /*------------------------------------------------------------------------*\
  2. |                                                                          |
  3. |           SLPOS2.CMD  - Version 1.0 - Version Date 1994-12-30            |
  4. |                         Version 2.0 - Version Date 1995-12-13            |
  5. |                         Version 3.0 - Version Date 1996-11-12            |
  6. |               Copyright (C) 1994-96 by C F S Nevada, Inc                 |
  7. |                                                                          |
  8. |                  by Dick Goran  - Voice    702-732-9616                  |
  9. |                                 - FAX      702-732-3847                  |
  10. |                                 - CIS      71154,2002                    |
  11. |                                 - Internet dgoran@cfsrexx.com            |
  12. |                                                                          |
  13. | ------------------------------------------------------------------------ |
  14. |  REXXLIB.DLL  - OS/2 REXX external function library                      |
  15. |                 (c) Copyright 1992-94 Quercus Systems                    |
  16. |                 is used only in the event of a REXX trap and is optional.|
  17. \*------------------------------------------------------------------------*/
  18.  
  19. say "  ╔════════════════════════════════════════════════════════════════════╗"
  20. say "  ║ THIS PROGRAM PRESUMES THAT YOUR SEIKO LABEL PRNTER FUNCTIONS UNDER ║"
  21. say "  ║ NATIVE DOS. IF THIS IS NOT THE CASE, PLEASE DON'T BOTHER RUNNING   ║"
  22. say "  ║ THIS PROGRAM.                                                      ║"
  23. say "  ╚════════════════════════════════════════════════════════════════════╝"
  24.  
  25. /*
  26.  
  27.    This program creates a DOS full screen session object for SLP /
  28.    SLPPRO use. Also, it creates a .BAT file (SLP-INIT.BAT) in the SLP
  29.    / SLPPRO directory.
  30.  
  31.    It may be necessary to adjust the value assigned to the variables
  32.    SLP_DRIVER and COM_PORT below.
  33.  
  34.    There is no currently no perceptible means of allowing label printing
  35.    to continue if the Seiko session is switched to the background.
  36.  
  37.    This program may be distributed free of charge and without any
  38.    warranty so long as the enclosed copyright remains intact.
  39.  
  40.    Updates:
  41.    --------
  42.    12/13/95 2.0   Correct error when asking for SLP path choice when no
  43.                   choices exist.
  44.                   Setup string changes including SESSION_PRIORITY when
  45.                   running under Warp.
  46.  
  47.    11/11/96 3.0   Change boot drive retrieval method
  48.                   Changed VDM settings
  49.                   Tset under Warp 4 with SLP PRO printer
  50. */
  51.  
  52. /*---------------------------------------*\
  53. |  Adjust the next two values within the  |
  54. |    quotes (apostrophes) as necessary    |
  55. \*---------------------------------------*/
  56. SLP_DRIVER = 'SLPPRO.SYS'           /* must contain driver name  */
  57. COM_PORT   = 'COM3'                 /* must contain correct COM? */
  58. /*----------------------------------------*\
  59. |  Adjust the above two values within the  |
  60. |    quotes (apostrophes) as necessary     |
  61. \*----------------------------------------*/
  62.  
  63.  
  64. GBL. = ''             /* initialize stem */
  65. parse Arg             GBL.command_line
  66. parse Version         GBL.REXX_version,
  67.                       GBL.REXX_version_level,
  68.                       GBL.REXX_version_day,
  69.                       GBL.REXX_version_month,
  70.                       GBL.REXX_version_year .
  71. parse upper Source    GBL.operating_system,
  72.                       GBL.calling_environment,
  73.                       GBL.program_path_and_name
  74. GBL.environment     = 'OS2ENVIRONMENT'
  75. GBL.program_version = 3.0           /* version / mod of this program */
  76. GBL.program_name    = STRIP( FILESPEC( 'N', GBL.program_path_and_name ) )
  77. GBL.program_path    = STRIP( FILESPEC( 'D', GBL.program_path_and_name ) ||,
  78.                              FILESPEC( 'P', GBL.program_path_and_name ) )
  79. parse upper value VALUE( 'PATH',, GBL.environment ) with '\OS2\SYSTEM' -2,
  80.                       GBL.boot_drive                                       +2
  81.  
  82. parse var GBL.program_name,
  83.    GBL.program_fn '.',
  84.    GBL.program_fe
  85. call TIME 'E'                       /* set elapsed timer - sssss.uuuuu */
  86. say 'Begin' GBL.program_name 'at' TIME('N')
  87.  
  88. /*---------------*\
  89. |  Register APIs  |
  90. \*---------------*/
  91. /* REXXUTIL */
  92. if RxFuncQuery( 'SysLoadFuncs' ) ¬= 0 then
  93.    do
  94.       call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  95.       call SysLoadFuncs
  96.    end
  97.  
  98. GBL.warp      = ( RxFuncQuery( 'SysMoveObject' ) = 0 )
  99. GBL.warp_peer = ( SysIni( 'USER', 'PM_Workplace:Location', '<PEER_LOGOFF>' ) ¬= 'ERROR:' )
  100. GBL.warp_40   = ( SysIni( 'USER', 'PM_Workplace:Location', '<WP_HWMGR>' )    ¬= 'ERROR:' )
  101.  
  102. /*------------------------*\
  103. |  Enable trap processing  |
  104. \*------------------------*/
  105.    SIGNAL ON ERROR
  106.    SIGNAL ON FAILURE
  107.    SIGNAL ON HALT
  108.    SIGNAL ON NOVALUE
  109.    SIGNAL ON SYNTAX
  110.  
  111. /*------------------------*\
  112. |  Box drawing characters  |
  113. \*------------------------*/
  114. dbl.h     = '═'                     /* double line - horizontal            */
  115. dbl.v     = '║'                     /* double line - vertical              */
  116. dbl.bl    = '╚'                     /* double line - bottom left           */
  117. dbl.br    = '╝'                     /* double line - bottom right          */
  118. dbl.tl    = '╔'                     /* double line - top left              */
  119. dbl.tr    = '╗'                     /* double line - top right             */
  120. dbl.t_d   = '╦'                     /* double line - "T" down              */
  121. dbl.t_l   = '╣'                     /* double line - "T" left              */
  122. dbl.t_r   = '╠'                     /* double line - "T" right             */
  123. dbl.t_u   = '╩'                     /* double line - "T" up                */
  124. dbl.cross = '╬'                     /* double line - cross bar             */
  125.  
  126. /*------------------------------------*\
  127. |  Determine if COM.SYS / VCOM.SYS is  |
  128. |  being used vs. SIO.SYS / VSIO.SYS   |
  129. \*------------------------------------*/
  130. COM_SYS_in_use = 0
  131. SIO_SYS_in_use = 0
  132.  
  133. config_sys_path_and_name =,
  134.    GBL.boot_drive || '\CONFIG.SYS'
  135. config_sys_size =,
  136.    STREAM( config_sys_path_and_name, 'C', 'QUERY SIZE' )
  137. config_sys_area =,
  138.    TRANSLATE( CHARIN( config_sys_path_and_name, 1, config_sys_size ) )
  139. call STREAM config_sys_path_and_name, 'C', 'CLOSE'
  140.  
  141. COM_SYS_search_arg =,
  142.    '0D0A'x                     ||,
  143.    'DEVICE='                   ||,
  144.    TRANSLATE( GBL.boot_drive ) ||,
  145.    '\OS2\BOOT\COM.SYS'
  146. if POS( COM_SYS_search_arg, config_sys_area ) > 0 then
  147.    do
  148.       COM_SYS_in_use = 1
  149.    end
  150. else
  151.    do
  152.       SIO_SYS_in_use = DETERMINE_IF_SIO_IN_USE()
  153.       com1_value = ( RIGHT( com_port, 1 ) = 1 )
  154.       com2_value = ( RIGHT( com_port, 1 ) = 2 )
  155.       com3_value = ( RIGHT( com_port, 1 ) = 3 )
  156.       com4_value = ( RIGHT( com_port, 1 ) = 4 )
  157.    end
  158.  
  159. /*---------------------------------------*\
  160. |  Attempt to determine SLP drive & path  |
  161. \*---------------------------------------*/
  162. slp_path   = FIND_SLP_PATH()
  163. if slp_path = '' then
  164.    do
  165.       say 'Unable to determine SLP path'
  166.       call EOJ
  167.    end
  168.  
  169. /*--------------------------------------------------------------*\
  170. |  Build OS/2 object on Dektop and put shadow in STARTUP folder  |
  171. \*--------------------------------------------------------------*/
  172. device_list =,
  173.    'SIZE=0 ' || GBL.boot_drive || '\OS2\MDOS\ANSI.SYS,'     ||,
  174.    'SIZE=0 ' || slp_path || slp_driver
  175.  
  176. slp_bat_file     = slp_path ||,
  177.                    'SLP-INIT.BAT'
  178. slp_location     = '<WP_DESKTOP>'
  179. slp_class        = 'WPProgram'
  180. slp_title        = 'SEIKO Label^Printer'
  181. slp_object_id    = '<' || TRANSLATE( slp_title, ' ', '^' ) || '>'
  182.  
  183. slp_setup_string =,
  184.    'EXENAME=command.com;'                                  ||,
  185.    'PARAMETERS=/k' slp_bat_file || ';'                     ||,
  186.    'CCVIEW=NO;'                                            ||,
  187.    'ICONFILE=' || GBL.program_path || 'SLPOS2.ICO;'        ||,
  188.    'MINIMIZED=NO;'                                         ||,
  189.    'PROGTYPE=VDM;'                                         ||,
  190.    'SET AUDIO_ADAPTER_SHARING=None;'                       ||,
  191.    'SET DOS_BACKGROUND_EXECUTION=1;'                       ||,
  192.    'SET DOS_DEVICE=' || device_list || ';'                 ||,
  193.    'SET DOS_HIGH=1;'                                       ||,
  194.    'SET DOS_UMB=1;'                                        ||,
  195.    'SET DPMI_DOS_API=DISABLED;'                            ||,
  196.    'SET DPMI_MEMORY_LIMIT=0;'                              ||,
  197.    'SET HW_ROM_TO_RAM=1;'                                  ||,
  198.    'SET HW_TIMER=1;'                                       ||,
  199.    'SET IDLE_SECONDS=60;'                                  ||,
  200.    'SET IDLE_SENSITIVITY=100;'                             ||,
  201.    'SET INT_DURING_IO=1;'                                  ||,
  202.    'SET KBD_ALTHOME_BYPASS=1;'                             ||,
  203.    ''
  204.  
  205. /* COM.SYS vs. SIO.SYS differences */
  206. if SIO_SYS_in_use ¬= 0 then
  207.    do
  208.       slp_setup_string =,
  209.          slp_setup_string                                  ||,
  210.          'SET SIO_Allow_Access_COM1=' || com1_value || ';' ||,
  211.          'SET SIO_Allow_Access_COM2=' || com2_value || ';' ||,
  212.          'SET SIO_Allow_Access_COM3=' || com3_value || ';' ||,
  213.          'SET SIO_Allow_Access_COM4=' || com4_value || ';' ||,
  214.          'SET SIO_Mode_FIFO_Load_Count=1;'                 ||,
  215.          'SET SIO_Mode_OCTS=Ignore CTS During Transmit;'   ||,
  216.          'SET SIO_Mode_RTS=No Change at OPEN or CLOSE;'    ||,
  217.          'SET SIO_Mode_XON/XOFF=Received XON is flow control;' ||,
  218.          ''
  219.    end
  220. else
  221.    do
  222.       slp_setup_string =,
  223.          slp_setup_string                            ||,
  224.          'SET COM_DIRECT_ACCESS=1;'                  ||,
  225.          'SET COM_HOLD=1;'                           ||,
  226.          'SET COM_SELECT=' || com_port ||';'         ||,
  227.          ''
  228.    end
  229.  
  230. /* Session priority requires Warp */
  231. if GBL.warp then
  232.    do
  233.       slp_setup_string =,
  234.          slp_setup_string                            ||,
  235.          'SET SESSION_PRIORITY=32;'                  ||,
  236.          ''
  237.    end
  238.  
  239. /* object ID always last */
  240. slp_setup_string =,
  241.    slp_setup_string                    ||,
  242.    'OBJECTID=' || slp_object_id || ';' ||,
  243.    ''
  244.  
  245. call SysCreateObject slp_class,,
  246.                      slp_title,,
  247.                      slp_location,,
  248.                      slp_setup_string,,
  249.                      'REPLACE'
  250. if RESULT = 1 then
  251.    do
  252.       say slp_title ||,
  253.           ' created successfully'
  254.       /*----------------------------------------------------------------------*\
  255.       |  Remove comment (/* & */ pair) lines surrounding the following state-  |
  256.       |  ments to have Seiko label printer shadowed to your Startup folder     |
  257.       \*----------------------------------------------------------------------*/
  258.       /* Remove this line to shadow Seiko Label printer to Startup folder
  259.       call SysCreateShadow slp_object_id, '<WP_START>'
  260.       if RESULT = 1 then
  261.          do
  262.             say slp_title ||,
  263.                 ' has been shadowed to your Statup folder'
  264.          end
  265.       else
  266.          do
  267.             say 'Unable to shadow ' ||,
  268.                 slp_title           ||,
  269.                 ' to your Statup folder'
  270.          end
  271.          Remove this line to shadow Seiko Label printer to Startup folder */
  272.    end
  273. else
  274.    do
  275.       say 'Unable to create ' ||,
  276.           slp_title
  277.    end
  278.  
  279. /*--------------------------*\
  280. |  Create SLP-INIT.BAT file  |
  281. \*--------------------------*/
  282. parse value slp_driver with,
  283.    fn '.' fext                      /* SLPPRO */
  284.  
  285. b=0
  286. b=b+1; bat_line.b = '@echo off'
  287. b=b+1; bat_line.b = 'rem ╔═══════════════════════════════════════════════════════════════════╗'
  288. b=b+1; bat_line.b = 'rem ║ The following MODE statement is not necessary if your DOS session ║'
  289. b=b+1; bat_line.b = 'rem ║ is normally 25 lines by 80 columns.                               ║'
  290. b=b+1; bat_line.b = 'rem ╚═══════════════════════════════════════════════════════════════════╝'
  291. b=b+1; bat_line.b = 'mode co80,25'
  292. b=b+1; bat_line.b = 'SET PROMPT=$e[0;37;44m$t$h$h$h $p$e $e[m '
  293. b=b+1; bat_line.b = FILESPEC( 'D', slp_path )
  294. b=b+1; bat_line.b = 'cd' STRIP( FILESPEC( 'P', slp_path ), 'T', '\' )
  295. b=b+1; bat_line.b = 'lh ' || fn || ' /R'
  296. b=b+1; bat_line.b = 'cls'
  297.        bat_line.0 = b
  298.  
  299. call SysFileDelete slp_bat_file
  300. do b = 1 to bat_line.0
  301.    call LINEOUT slp_bat_file, bat_line.b
  302. end
  303. call STREAM slp_bat_file, 'C', 'CLOSE'
  304.  
  305. call EOJ 0
  306.  
  307.  
  308. /*------------------------------------------------------------------------*\
  309. |                                                                          |
  310. |    Try to determine from CONFIG.SYS if Gwinn's SIO / VSIO are in use     |
  311. |                                                                          |
  312. \*------------------------------------------------------------------------*/
  313. DETERMINE_IF_SIO_IN_USE:
  314.    Procedure expose,
  315.       GBL.,
  316.       config_sys_area
  317. parse value config_sys_area with,
  318.    pre_SIO_SYS,
  319.    '\SIO.SYS ',
  320.    post_SIO_SYS
  321.  
  322. if post_SIO_SYS = '' then
  323.    do
  324.       return 0                      /* can't find \SIO.SYS */
  325.    end
  326. crlf_pos = LASTPOS( '0D0A'x, pre_SIO_SYS ) /* find end of previous line */
  327. if crlf_pos = 0 then
  328.    do
  329.       return 0                      /* can't find previous cr / lf */
  330.    end
  331. SIO_SYS_line_beginning =,
  332.    RIGHT( pre_SIO_SYS, LENGTH( pre_SIO_SYS ) - crlf_pos - 1 )
  333. if LEFT( SIO_SYS_line_beginning, 7 ) ¬= 'DEVICE=' then
  334.    do
  335.       return 0                      /* line may be commented out */
  336.    end
  337. SIO_SYS_line_beginning_pos = crlf_pos + 2
  338. parse value config_sys_area with,
  339.    . =(SIO_SYS_line_beginning_pos),
  340.    SIO_SYS_line,
  341.    '0D0A'x .
  342.  
  343. return SIO_SYS_line
  344.  
  345. /*------------------------------------------------------------------------*\
  346. |                                                                          |
  347. |                              Find SLP Path                               |
  348. |                                                                          |
  349. \*------------------------------------------------------------------------*/
  350. FIND_SLP_PATH:
  351.    Procedure expose,
  352.       GBL.
  353.  
  354. say 'Searching for directory containing Seiko Label Printer files'
  355. say '   (Please be patient)'
  356. potential_slp_path_table.0 = 0      /* initialize table count */
  357.  
  358. drive_list = SysDriveMap( 'C', 'LOCAL' ) /* get a list of all drives */
  359.  
  360. do drive_number = 1 to WORDS( drive_list )
  361.  
  362.    drive_letter_colon    = WORD( drive_list, drive_number )
  363.    parse value SysDriveInfo( drive_letter_colon ) with,
  364.       . free_bytes . .
  365.    if free_bytes = '',
  366.          |,
  367.       free_bytes = 0 then
  368.       do
  369.          iterate drive_number
  370.       end
  371.  
  372.    /*---------------------------------------------*\
  373.    |  Look for SLP*.SYS as a tentative indication  |
  374.    \*---------------------------------------------*/
  375.    call SysFileTree drive_letter_colon || '\SLP*.SYS',,
  376.                     'slp_sys_stem',,
  377.                     'FS'
  378.    if slp_sys_stem.0 = 0 then iterate  /* ignore this drive */
  379.  
  380.    /*----------------------------*\
  381.    |  Add to potential path list  |
  382.    \*----------------------------*/
  383.    do sss = 1 to slp_sys_stem.0
  384.       parse value slp_sys_stem.sss with,
  385.          slp_sys_date,
  386.          slp_sys_time,
  387.          slp_sys_size,
  388.          slp_sys_attr,
  389.          slp_sys_path_and_name
  390.       slp_sys_path_and_name = STRIP( slp_sys_path_and_name )
  391.  
  392.       p = potential_slp_path_table.0 + 1
  393.       potential_slp_path_table.0 = p
  394.       potential_slp_path_table.p = FILESPEC( 'D', slp_sys_path_and_name ) ||,
  395.                                    FILESPEC( 'P', slp_sys_path_and_name )
  396.    end
  397.  
  398. end
  399.  
  400. select
  401.    when potential_slp_path_table.0 = 1 then
  402.       do
  403.          return potential_slp_path_table.1
  404.       end
  405.    when potential_slp_path_table.0 = 0,
  406.                |,
  407.         potential_slp_path_table.0 > 9 then
  408.       do forever
  409.          /*-----------------------------*\
  410.          |  Ask user to supply SLP path  |
  411.          \*-----------------------------*/
  412.          say 'Enter path where Seiko label printer files were installed.'
  413.          pull reply
  414.          test_path = reply
  415.          if RIGHT( test_path, 1 ) ¬= '\' then
  416.             do
  417.                test_path = test_path || '\'
  418.             end
  419.          call SysFileTree test_path || '*.*', 'test_stem', 'F'
  420.          if test_stem.0 > 0 then
  421.             do
  422.                return test_path
  423.             end
  424.          say reply ||,
  425.              ' is not a valid path'
  426.          say ''
  427.       end
  428.    otherwise
  429.       do forever
  430.          /*-----------------------------------*\
  431.          |  Ask which one to select from list  |
  432.          \*-----------------------------------*/
  433.          say 'Enter the number associated with the correct SLP path:'
  434.          do p = 1 to potential_slp_path_table.0
  435.             say COPIES( ' ', 3 )             ||,
  436.                 p                            ||,
  437.                 COPIES( ' ', 2 )             ||,
  438.                 STRIP( potential_slp_path_table.p, 'T', '\' )
  439.          end
  440.          pull p
  441.          if ( p > 0 )  &  ( p <= potential_slp_path_table.0 ) then
  442.             do
  443.                return potential_slp_path_table.p
  444.             end
  445.          say '   Error. Reply must be between 1 and ' ||,
  446.              potential_slp_path_table.0
  447.          say ''
  448.       end
  449. return ''
  450. end
  451.  
  452.  
  453. /*------------------------------------------------------------------------*\
  454. |                                                                          |
  455. |                                End of Job                                |
  456. |                                                                          |
  457. \*------------------------------------------------------------------------*/
  458. EOJ:
  459.    Procedure expose,
  460.       GBL.
  461.  
  462. if ARG() = 0 then
  463.    eoj_rc = 0
  464. else
  465.    eoj_rc = ARG(1)
  466.  
  467. elapsed_time = TIME('E')            /* get elapsed time - sssss.uuuuu */
  468. parse value elapsed_time with seconds '.' micro_seconds
  469. if LEFT( micro_seconds, 1, 1 ) >= 5 then
  470.    seconds = seconds + 1
  471. ss = FORMAT( seconds // 60, 2 )
  472. minutes = ( seconds - ss ) / 60
  473. mm = FORMAT( minutes // 60, 2 )
  474. hh = FORMAT( ( minutes - mm ) / 60, 2 )
  475. duration = hh':'mm':'ss
  476.  
  477. program_name = TRANSLATE( FILESPEC( 'N', GBL.program_path_and_name ) )
  478. say 'EOJ  ' program_name 'at' TIME('N') ||,
  479.     ', duration' TRANSLATE( duration, '0', ' ' )
  480. exit eoj_rc
  481.  
  482.  
  483. !tr! = VALUE('TRACE',,GBL.environment); if !tr! ¬= '' then do; TRACE(!tr!); nop; end
  484. /*------------------------------------------------------------------------*\
  485. |                                                                          |
  486. |                              Trap Routines                               |
  487. |                                                                          |
  488. \*------------------------------------------------------------------------*/
  489. ERROR:   call TRAP_PROCESSING SIGL, 'ERROR',   RC
  490. FAILURE: call TRAP_PROCESSING SIGL, 'FAILURE', RC
  491. HALT:    call TRAP_PROCESSING SIGL, 'HALT',    ''
  492. NOVALUE: call TRAP_PROCESSING SIGL, 'NOVALUE', ''
  493. SYNTAX:  call TRAP_PROCESSING SIGL, 'SYNTAX',  RC
  494.  
  495. /* Rev. 95/10/14 */
  496. TRAP_PROCESSING:
  497.    parse Source . . TRAP.path_and_program
  498.    trap.line_nbr = ARG(1)
  499.    if POS( ':', TRAP.path_and_program ) > 0 then
  500.       /* get source line if it is available */
  501.       do t = 1
  502.          trap_source_line.t =  SOURCELINE( trap.line_nbr )
  503.          trap_source_line.0 = t
  504.          trap.line_nbr      = trap.line_nbr + 1
  505.          if RIGHT( trap_source_line.t, 1 ) ¬= ',' then
  506.             do
  507.                leave
  508.             end
  509.       end
  510.    else
  511.       /* program is running in macrospace */
  512.       do
  513.          TRAP.path_and_program = STRIP( DIRECTORY(), 'T', '\' ) || '\' ||,
  514.                                  TRAP.path_and_program
  515.          trap_source_line.1 = 'Source line is not available.'
  516.          trap_source_line.0 = 1
  517.       end
  518.  
  519.    parse value FILESPEC( 'N', TRAP.path_and_program ) with,
  520.       TRAP.fn '.' TRAP.fe
  521.    trap_file_name = FILESPEC( 'D', TRAP.path_and_program ) ||,
  522.                     FILESPEC( 'P', TRAP.path_and_program ) ||,
  523.                     TRAP.fn || '.' || 'DMP'
  524.  
  525.    /*------------------------------------------*\
  526.    |  check for reason not to create .DMP file  |
  527.    \*------------------------------------------*/
  528.    if ARG(2) = 'HALT' then
  529.       do
  530.          trap_file_name = ''
  531.       end
  532.    if RxFuncQuery( 'VARDUMP' ) ¬= 0 then
  533.       do
  534.          trap_file_name = ''
  535.       end
  536.    if POS( ':', trap_file_name ) = 0 then
  537.       do
  538.          trap_file_name = ''
  539.       end
  540.  
  541.    /*------------------------*\
  542.    |  Build trap message box  |
  543.    \*------------------------*/
  544.    dbl.h    = 'CD'x                 /* ═ double line - horizontal   */
  545.    dbl.v    = 'BA'x                 /* ║ double line - vertical     */
  546.    dbl.bl   = 'C8'x                 /* ╚ double line - bottom left  */
  547.    dbl.br   = 'BC'x                 /* ╝ double line - bottom right */
  548.    dbl.tl   = 'C9'x                 /* ╔ double line - top left     */
  549.    dbl.tr   = 'BB'x                 /* ╗ double line - top right    */
  550.    trap.red = '1B'x || '[1;37;41m'  /* bright white on red          */
  551.    trap.dul = '1B'x || '[0m'        /* reset to normal              */
  552.  
  553.    say ' '
  554.    trap_error_description =,
  555.       'Error line = ' || ARG(1) ||,
  556.       '; ' ||,
  557.       ARG(2) ||,
  558.       ' error.'
  559.    if ARG(3) ¬= '' then
  560.       trap_error_description = trap_error_description ||,
  561.                                '  Return code = ' || ARG(3)
  562.    trap.width = MAX( 74, LENGTH( trap_error_description ) )
  563.    say trap.red || dbl.tl || COPIES( dbl.h,trap.width + 2 ) || dbl.tr || trap.dul
  564.    say trap.red || dbl.v  || COPIES( ' ',  trap.width + 2 ) || dbl.v  || trap.dul
  565.    say trap.red || dbl.v CENTER( TRAP.fn'.'TRAP.fe,trap.width )    dbl.v  || trap.dul
  566.    say trap.red || dbl.v CENTER( trap_error_description, trap.width ) dbl.v || trap.dul
  567.    if trap_file_name ¬= '' then
  568.       do
  569.    say trap.red || dbl.v  || COPIES( ' ',  trap.width + 2 ) || dbl.v  || trap.dul
  570.    say trap.red || dbl.v     CENTER( 'See: ' || trap_file_name,,
  571.                                      trap.width )  dbl.v  || trap.dul
  572.       end
  573.    say trap.red || dbl.v  || COPIES( ' ',  trap.width + 2 ) || dbl.v  || trap.dul
  574.    say trap.red || dbl.bl || COPIES( dbl.h,trap.width + 2 ) || dbl.br || trap.dul
  575.    say trap.red || COPIES( ' ', trap.width + 4 ) || trap.dul
  576.    say trap.red || LEFT( 'Source line(s) at time of trap:', trap.width + 4 ) || trap.dul
  577.    do t = 1 to trap_source_line.0
  578.       say trap.red || LEFT( '   ' || trap_source_line.t, trap.width + 4 ) || trap.dul
  579.    end
  580.    say trap.red || COPIES( ' ', trap.width + 4 ) || trap.dul
  581.  
  582.    /*---------------------------------*\
  583.    |  Create .DMP file if appropriate  |
  584.    \*---------------------------------*/
  585.    if trap_file_name ¬= '' then
  586.       do
  587.          call SysFileDelete trap_file_name
  588.          /* remove meaningless labels from dump for clarity */
  589.          drop dbl. TRAP. RC RESULT SIGL !tr!
  590.          call VARDUMP trap_file_name  /* write variables to program.DMP file */
  591.       end
  592.    exit 253
  593.