home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rximc175.zip / box next >
Text File  |  1999-01-23  |  2KB  |  36 lines

  1. /*bin/true;exec rexx -x "$0" "$@";exit# This is a REXX program */
  2. parse arg args
  3. if args="" then args="/usr/games/fortune"/* default command */
  4. args "| expand | rxstack"            /* stack the command's output */
  5. if rc<>0 then exit rc                /* exit on error */
  6. l=0                                  /* zero maximum length */
  7. s=1e9                                /* minimum space on left */
  8. do i=1 for queued()                  /* pull each line */
  9.    parse pull line.i
  10.    line.i=strip(translate(line.i,,xrange('00'x,'1f'x)||xrange('7f'x)),'T')
  11.                                      /* translate all characters outside the
  12.                                         range 0x20 - 0x7e into spaces.
  13.                                         Remove trailing spaces. */
  14.    l1=length(line.i)
  15.    l2=spc(line.i)
  16.    if l<l1 then l=l1                 /* keep maximum length */
  17.    if s>l2 then s=l2                 /* keep minimum left space */
  18. end
  19. if s=1e9 then s=0                    /* just in case no output */
  20. l=l-s
  21. lines=copies("_",l+4)                /* top and bottom */
  22. cent=33-l%2                          /* calculate the number */
  23. if cent<1 then cent=""               /* of spaces before each */
  24. else cent=copies(" ",cent)           /* line */
  25. say cent lines                       /* output top */
  26. say cent"|"copies(" ",l+4)"|"        /* output a blank line */
  27. do j=1 to i-1
  28.    say cent"|  "substr(line.j,s+1,l+2)"|"/* output each line of text */
  29. end
  30. say cent"|"lines"|"                  /* output bottom */
  31. return
  32. spc: /* return the number of spaces on the left */
  33. parse arg t
  34. if t='' then return 0
  35. else return verify(t,' ')-1
  36.