© gilbertsaint-flour@newsgroup

The program receives a character string which will be translated into capitals. Every letter is 6 lines high. The conversion operates depending on the type of terminal up to 80 or 132 columns. The result is provided in the stack, please see also remarks in the comments.


/*************************REXX Exec BIGLTRS**************************/
CALL Init_Big_Letters               /* initialize big letters tables  */
PARSE UPPER ARG string              /* get text to be displayed       */
str_len = LENGTH(string)            /* get length of text string      */
/*
  This code breaks the text string passed to BIGLTRS down into
  multiple groups. Each group is the number of letters that will
  fit on one line of the screen. For an 80-character terminal 13
  letters will fit on a line. For a 132-character terminal 21
  letters will fit on a line. So if 25 letters are to be displayed
  on an 80-character terminal they will be broken down into two
  groups, one of which is 13-letters in length and one of 12 letters
  in length
*/
ltr_group_idx = 0                   /* init ltr_group_idx             */
ltrs_per_line = 13                  /* show 13 letters per line       */
If ADDRESS() = 'CMS' THEN           /* if we're running under CMS     */
   DO                               /*    do                          */
     ADDRESS CMS "Q DISPLAY (STACK" /*      get terminal width        */
     PARSE PULL . . term_width ,    /*      pull term width from stack*/
        . . . . . . . .             /*         don't need these       */
   END                              /*    end                         */
ELSE                                /* else                           */
   term_width = SYSVAR(syswterm)    /*     assume tso - get term width*/
IF term_width = 132 THEN            /* if 132-column terminal         */
   ltrs_per_line = 21               /*    show 21 letters per line    */
DO i = 1 to LENGTH(string) ,        /* do once for each set of ltrs   */
       by ltrs_per_line             /*    that will fit on a line     */
   ltr_group_idx = ,                /*    incr ltr_group_idx          */
      ltr_group_idx + 1             /*                                */
   ltr_group.ltr_group_idx = ,      /*    break text string down into */
      SUBSTR(string,i,ltrs_per_line)/*    terminal-width-sized pieces */
END                                 /* end                            */
ltr_group.0 = ltr_group_idx         /* save number of letter-groups   */
/*
  This code is made up of two DO-END loop structures. The outer loop
  is executed once for each line of output. The inner loop is done
  once for each individual letter in that line
*/
DO ltr_group_ctr = 1 to ltr_group.0 /* do once for each line of ltrs  */
   CALL Big_Letters                 /*    bld big letters array       */
   DO ltr_segment = 1 to 6          /*    do once for each big letter */
                                    /*       segment                  */
      QUEUE line.ltr_segment        /*       send segment to stack    */
   END                              /*    end                         */
END                                 /* end                            */

RETURN                              /* return to caller               */

Big_Letters:
  /*
    Each big letter is six terminal lines high. The first one is
    blank and the remaining 5 are composed of the segments that
    make up each letter.

    Table T0 contains all of the letters that may be turned into big
    letters. Tables T1 through T5 contain the segments of each big
    letter that are displayed in the corresponding lines 2 through 5 of
    the terminal output.

    This subroutine uses the individual letter position in table T0 to
    calculate the position of each segment of the corresponding big
    letter in tables T1 through T5.

    The six-line-high output of each string of letters is constructed in
    this subroutine. A string of letters is the number of letters that
    will fit on one terminal line. For 80-column terminals a string will
    be a maximum of 13 letters wide. For 132-column terminals a string
    will be a maximum of 21 letters wid.

    The compound variable ltr_group. contains each string of (up to)
    13 or 21 letters. The variable ltr_group_ctr keeps track of which
    letter in the group we're working on. The variable ltr_ctr keeps
    track of which big letter we're building. The variable ltr_seg
    keeps track of which segment of the big letter is being constructed.
*/

  DO ltr_seg = 1 to 6               /* do once for each segment of ltr*/
     line.ltr_seg = ''              /*    initialize output line      */
  END                               /* end                            */

  DO ltr_ctr = 1 TO ,               /* do once for each letter in this*/
     LENGTH(ltr_group.ltr_group_ctr)/*    letter group                */
    ltr = ,                         /*    isolate current letter      */
      SUBSTR(ltr_group.ltr_group_ctr, ltr_ctr,1)
    tbl_pos = INDEX(t0,ltr) - 1     /*    get pos offset of ltr in tbl*/
    IF tbl_pos < 0 THEN             /* if letter not in table t0      */
       ITERATE                      /*    get next letter             */
    tbl_pos = tbl_pos * 5           /*    calculate letter position   */
    tbl_pos = tbl_pos + 1           /*       in big letter table      */
    ltr_seg = 2                     /*    move to 2nd line of output  */
    line.ltr_seg = line.ltr_seg !!, /*    bld 1st line of big ltr     */
      SUBSTR(t1,tbl_pos,5) !! ' '
    ltr_seg = ltr_seg + 1           /*    skip to next letter segment */
    line.ltr_seg = line.ltr_seg !!, /*    bld 2nd line of big ltr     */
      SUBSTR(t2,tbl_pos,5) !! ' '
    ltr_seg = ltr_seg + 1           /*    skip to next letter segment */
    line.ltr_seg = line.ltr_seg !!, /*    bld 3rd line of big ltr     */
      SUBSTR(t3,tbl_pos,5) !! ' '
    ltr_seg = ltr_seg + 1           /*    skip to next letter segment */
    line.ltr_seg = line.ltr_seg !!, /*    bld 4th line of big ltr     */
      SUBSTR(t4,tbl_pos,5) !! ' '
    ltr_seg = ltr_seg + 1           /*    skip to next letter segment */
    line.ltr_seg = line.ltr_seg !!, /*    bld 5th line of big ltr     */
      SUBSTR(t5,tbl_pos,5) !! ' '
    ltr_seg = ltr_seg + 1           /*    skip to next letter segment */
  END                               /* end                            */
RETURN

Init_Big_Letters:
T0='ABCDEFGHIJKLMNOPQRSTUVWXYZ#,$0123456789@%*/-()&+_¢!>:;.?"=!<^ \'
t0=t0"'"

T1=  '  A  BBBB  CCCCDDDD EEEEEFFFFF GGGGH   H III   JJJK  K L    M   M'
T2=  ' A A B   BC    D   DE    F    G    H   H  I     J K K  L    MM MM'
T3=  'A   ABBBB C    D   DEEEE FFFF G  GGHHHHH  I     J KK   L    M M M'
T4=  'AAAAAB   BC    D   DE    F    G   GH   H  I  J  J K K  L    M   M'
T5=  'A   ABBBB  CCCCDDDD EEEEEF     GGGGH   H III  JJ  K  K LLLLLM   M'

T1=T1'N   NOOOOOPPPP  QQQ RRRR  SSSSTTTTTU   UV   VW   WX   XY   YZZZZZ'
T2=T2'NN  NO   OP   PQ   QR   RS      T  U   UV   VW   W X X  Y Y    Z '
T3=T3'N N NO   OPPPP Q Q QRRRR  SSS   T  U   UV   VW W W  X    Y    Z  '
T4=T4'N  NNO   OP    Q  Q R  R     S  T  U   U V V WW WW X X   Y   Z   '
T5=T5'N   NOOOOOP     QQ QR   RSSSS   T   UUU   V  W   WX   X  Y  ZZZZZ'

T1=T1' # #       $$$$ 000   1  2222 3333 4  4 55555 666 77777 888  999 '
T2=T2'#####     $ $  0  00 11      2    34  4 5    6       7 8   89   9'
T3=T3' # #       $$$ 0 0 0  1     2  333 444445555 6666   7   888  9999'
T4=T4'##### ,,    $ $00  0  1    2      3   4     56   6  7  8   8    9'
T5=T5' # #   ,  $$$$  000  111 222223333    4 5555  666   7   888  999 '

T1=T1' @@@ %%  %* * *    /        (  )    &&&   +         *    !   >   '
T2=T2'@   @   %  ***    /        (    )  &      +        C*C   !    >  '
T3=T3'@ @@   %  *****  /  -----  (    )   &&  +++++     C *    !     > '
T4=T4'@     %    ***  /          (    )  &   &  +        C*C   !    >  '
T5=T5' @@@@%  %%* * */            (  )    &&&&  +  _____  *    !   >   '

T1=T1' ..   ..        ???  " "       !!     <           \    '
T2=T2' ..   ..       ?   ?     ===== !!    <             \   '
T3=T3'                  ?            !!   <   ^^^^^       \  '
T4=T4' ..   ,,   ..    ?       =====       <      ^        \ '
T5=T5' ..    ,   ..    ?             ..     <               \'

T1=T1" ''"
T2=T2"  '"
T3=T3" "
T4=T4" "
T5=T5" "

RETURN
/***********************End REXX Exec BIGLTRS************************/
/*
 Program Name: BIGLTRS
 Date Written: AUGUST 26, 1998
       Author: Original Code - Gilbert Saint-flour

               External callable-exec mods:

               Michael A. Newell
               SYSTEM 2000 Development/Support
               SAS Institute Inc.
               Austin Regional Office
               Austin, TX

               NOTE: This exec is NOT supported by SAS Institute Inc.


 Acknowlegements: The BIGLTRS exec was originally part of the
                  WHOAMI exec. The WHOAMI exec was written by
                  Gilbert Saint-flour.

                  The INIT_BIG_LETTERS and BIG_LETTERS subroutines
                  in WHOAMI were broken out and turned into a
                  separate external routine, generalized so anyone
                  could call it.

  Description: This program accepts a text string from the caller
               and returns that string to the caller in big letters

               BIGLTRS is meant to be called from another exec, not
               run as a standalone program

       Syntax: CALL BIGLTRS 'text string'

               where 'text string' is the line of text to be converted
               to big letters.

               The text string can be almost any length, but will be
               divided into 13-character sets for 80-column terminals
               and 21-character sets for 132-column terminals.

      Example: Each big letter is six screen lines high. The BIGLTRS
               exec QUEUES each of these lines to the stack. The
               calling routine needs to pull each of these lines
               from the stack upon return from BIGLTRS, like this:

               /* REXX */
               CALL BIGLTRS 'abcde'
               DO i = 1 to QUEUED()
                  PARSE PULL line
                  SAY line
               END
               EXIT
*/

back to Help in Daily Life