10 2 Text String Processing

LANSA Application Design

10.2 Text String Processing

The LANSA RDML is quite good at string handling.  When this is combined with the flexibility of true subroutine parameters, a very simple method of assembling, (and in this case printing), text strings results.

Consider the following subroutine:

 SUBROUTINE NAME(PRINT_TEXT) PARMS(#S01 #S02 #S03 #S04 #S05)

    DEFINE     FIELD(#S01) TYPE(*CHAR) LENGTH(30)

    DEFINE     FIELD(#S02) TYPE(*CHAR) LENGTH(30)

    DEFINE     FIELD(#S03) TYPE(*CHAR) LENGTH(30)

    DEFINE     FIELD(#S04) TYPE(*CHAR) LENGTH(30)

    DEFINE     FIELD(#S05) TYPE(*CHAR) LENGTH(30)

    DEFINE     FIELD(#R01) TYPE(*CHAR) LENGTH(132)

    DEF_LINE   NAME(#R01L) FIELDS(#R01)

    USE        BUILTIN(BCONCAT) WITH_ARGS(#S01 #S02 #S03 #S04 #S05)

               TO_GET(#R01)

    PRINT      LINE(#R01L)

 ENDROUTINE

This subroutine can be used like this:

  EXECUTE PRINT_TEXT('''Product'''  +

                     #PRODNO +

                     '''is out of stock. Please contact'''

                     #SUPPLIER +

                     '''to order more.''')   

to print:

Product 836 is out of stock. Please contact ACME ENGINEERING to order more.

Or like this:

  EXECUTE PRINT_TEXT('''Your departmental supervisor'''  +

                     #TITLE +

                     #NAME +

                     '''should be informed of this error''' +

                     *BLANKS)  

to print:

Your departmental supervisor Ms Cullen should be informed of this error.