home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / prodtool / epm / e_macros / box.e < prev    next >
Encoding:
Text File  |  1991-06-11  |  4.5 KB  |  118 lines

  1. ;  For linking version, BOX can be an external command.
  2. ;  Script style suggested by Larry Salomon, Jr.
  3.  
  4. compile if not defined(SMALL)
  5. tryinclude 'MYCNF.E'
  6.  compile if not defined(NLS_LANGUAGE)
  7.   const NLS_LANGUAGE = 'ENGLISH'
  8.  compile endif
  9. include NLS_LANGUAGE'.e'
  10. compile endif
  11.  
  12. defmain     -- External modules always start execution at DEFMAIN.
  13.    'box' arg(1)
  14.  
  15. defc box=  /* give height width style */
  16.    universal tempofid
  17.  
  18.    uparg=upcase(arg(1))
  19.    msg =  BOX_ARGS__MSG
  20.    if not length(uparg) then
  21.       sayerror msg
  22. compile if EVERSION < 5        -- If not EPM
  23.       cursor_command; begin_line;erase_end_line;keyin 'Box '
  24. compile endif
  25.       stop
  26.    endif
  27.    if marktype()<>'BLOCK' then
  28.       sayerror -288  -- 'Block mark required'
  29.       stop
  30.    endif
  31.    flg=0
  32.    for ptr = 1 to length(uparg)
  33.       if flg then
  34.          style=substr(arg(1),ptr,1)
  35.       else
  36.          style=substr(uparg,ptr,1)
  37.       endif
  38.       if style='/' then
  39.          flg=1; iterate
  40.       endif
  41.       if not flg and verify(uparg,"123456BCPAERS") then
  42.          sayerror msg
  43. compile if EVERSION < 5        -- If not EPM
  44.          cursor_command; begin_line;erase_end_line;keyin 'Box '
  45. compile endif
  46.          stop
  47.       endif
  48.       call psave_pos(save_pos)
  49.       getmark firstline,lastline,firstcol,lastcol,fileid
  50.       if style='E' then
  51.          getline tline,firstline,fileid
  52.          getline bline,lastline,fileid
  53.          msg=BOX_MARK_BAD__MSG
  54.          if firstcol=1 or firstline=1 or lastline=fileid.last then
  55.             sayerror msg
  56.             stop
  57.          endif
  58.  
  59.          brc=substr(bline,lastcol+1,1)
  60.          lside=substr(tline,firstcol-1,1)
  61.          if lside='║' or lside='│' or lside=';' or lside='|' or lside='█'  then
  62.             sl=1
  63.          elseif lside='*' and firstcol>2 and  -- MAX prevents error if firstcol <= 2
  64.                               pos(substr(tline,max(firstcol-2,1),1),'{/.') then
  65.                sl=2
  66.          elseif brc=lside then
  67.             sl=1
  68.          else
  69.             sayerror msg
  70.             stop
  71.          endif
  72.          for i=firstline to lastline
  73.             getline line,i,fileid
  74.             replaceline substr(line,1,firstcol-sl-1)||substr(line,firstcol,lastcol+1-firstcol)||substr(line,lastcol+sl+1),i,fileid
  75.          endfor
  76.          deleteline lastline+1,fileid
  77.          deleteline firstline-1,fileid
  78.          call prestore_pos(save_pos)
  79.          call pset_mark( firstline-1,lastline-1,firstcol-sl,lastcol-sl,marktype(),fileid)
  80.       elseif style='R' then
  81.          if not pblock_reflow(0,spc,tempofid) then
  82.             call pblock_reflow(1,spc,tempofid)
  83.          endif
  84.          call prestore_pos(save_pos)
  85.       else
  86.          if flg then
  87.             lside=style;rside=style;tside=style;tlc=style;trc=style;blc=style;brc=style
  88.          else
  89.             if style='P' then lside='{*';rside='*}';tside='*';tlc='{*';trc='*}';blc='{*';brc='*}'
  90.             elseif style='A' then lside=';';rside=' ';tside='*';tlc=';';trc=' ';blc=';';brc=' '
  91.             elseif style='C' then lside='/*';rside='*/';tside='*';tlc='/*';trc='*/';blc='/*';brc='*/'
  92.             elseif style=1 then lside='│';rside='│';tside='─';tlc='┌';trc='┐';blc='└';brc='┘'
  93.             elseif style=2 then lside='║';rside='║';tside='═';tlc='╔';trc='╗';blc='╚';brc='╝'
  94.             elseif style=3 then lside='|';rside='|';tside='-';tlc='+';trc='+';blc='+';brc='+'
  95.             elseif style=4 then lside='█';rside='█';tside='▀';tlc='█';trc='█';blc='▀';brc='▀'
  96.             elseif style=5 then lside='│';rside='│';tside='═';tlc='╒';trc='╕';blc='╘';brc='╛'
  97.             elseif style=6 then lside='║';rside='║';tside='─';tlc='╓';trc='╖';blc='╙';brc='╜'
  98.             elseif style='S' then lside='.*';rside='**';tside='*';tlc='.*';trc='**';blc='.*';brc='**'
  99.             else   style='B';lside=' ';rside=' ';tside=' ';tlc=' ';trc=' ';blc=' ';brc=' '
  100.             endif
  101.          endif
  102.          sl=length(lside)
  103.          width=1+lastcol-firstcol   /* width of inside of box */
  104.          side=substr('',1,width,tside)
  105.          line = substr('',1,firstcol-1)||blc||side||brc
  106.          insertline line,lastline+1,fileid
  107.          insertline substr('',1,firstcol-1)||tlc||side||trc,firstline,fileid
  108.          for i=firstline+1 to lastline+1
  109.             getline line,i,fileid
  110.             replaceline substr(line,1,firstcol-1)||lside||substr(line,firstcol,width)||rside||substr(line,lastcol+1),i,fileid
  111.          endfor
  112.          call prestore_pos(save_pos)
  113.          call pset_mark(firstline+1,lastline+1,firstcol+sl,lastcol+sl,marktype(),fileid)
  114.       endif
  115.       flg=0
  116.    endfor
  117.  
  118.