PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: Resource Validation - Local[Next]: TEXTEDIT with PPWIZARD
\ -> Examples / Tips -> SHARING HEADERS - HTML + REXX CGI

SHARING HEADERS - HTML + REXX CGI

Whenever you use the #define command to define something you have already decided (whether or not you realise it) the contexts it can be used in.

As an example, you could create a definition which expands to a filename surrounded by double quotes; this can only be used in situations where the double quotes are required (or won't interfere). Your other major choice was not to supply double quotes; this then requires you to supply double quotes when used in situations where the quotes are required.

Sometimes you can have a mismatch between "languages" which mean that you will need to get "tricky" when creating definitions when a header file is shared, such as where a common header file is shared between HTML and REXX code (server CGI script for example).

You should understand that PPWIZARD has a /CGI mode, this example does not cover this at all. The REXX CGI script discussed in this example is generated by PPWIZARD and placed onto the web server for execution. When the /CGI mode is used, the header sharing issues discussed here, along with the solutions, are not relevant and in a lot of cases using this switch may be the simplest solution.

Some REXX CGI / HTML Issues

  1. REXX has a limit on the size of a literal. So if you had a standard HTML footer which successfully expands to 2000 characters in a HTML document, simply putting quotes around the text for REXX would result in a 2000 byte literal. The limit is more likely to be around 250 bytes!

  2. In a REXX CGI script it may be that some substituted text (macro parameter) may not be known until runtime whereas with HTML you are likely to be able to "hard code" it.

  3. Some REXX interpreters also have a limit on the maximum length of a command.

  4. There may be a maximum line limit in some REXX interpreters.

EXAMPLE - COMMON HEADER

;--- We need to get tricky to use some LONG macros in rexx code -------------
#if  ['<?ProcessingMode>' = 'REXX']
     ;--- We are generating REXX code (take care of OS/2 & REGINA restrictions on lengths of literals and clauses) ---
     #define   RexxAssignTo CgiVar           ;;The user must assign macro to this variable
     #define   RexxQuote  ' || "'" || '      ;;Used in place of any single quotes
     #define   RexxConcat ';<?NewLine><$RexxAssignTo> = <$RexxAssignTo> || '                 ;;End old & start new literal
#elseif
     ;--- We are generating HTML --------------------------------------------
     #define   RexxQuote    '                ;;Simply expand to single quote
     #define   RexxConcat
#endif

In the above "RexxConcat" is designed to be used "every so often" (within REXX's literal limit). When expanding in HTML it does nothing. In REXX code it finishes off the literal, statement and line then starts another.

The "RexxQuote" is designed to be used in place of any single quotes you might wish to output in the expanded text. There should be few of these as you will try to use double quotes everywhere.

The following shows how a large macro might make use of the above definitions (note that a lot of external macros are referenced which are not shown):

;--- Define Headings --------------------------------------------------------
#define TitleHtml                                                        \
        ;--- Start Html ------------------------------------------      -\
        <HTML>                                                          -\
        <HEAD>                                                          -\
        <$HtmlDebugNL>                                                  -\
        <TITLE>{$Title=^{$Text}^}</TITLE>                               -\
        #if '{$OTHERHEADER_TAGS=^^}' <> ''                              -\
             <$HtmlDebugNL>                                             -\
             {$OTHERHEADER_TAGS=^^}                                     -\
        #endif                                                          -\
        <$HtmlDebugNL>                                                  -\
        </HEAD>                                                         -\
                                                                        -\
        ;--- Set up Body tag -------------------------------------      -\
        <$HtmlDebugNL>                                                  -\
        <$BodyStandardOs2Warp>                                          -\
        <$RexxConcat>                                                   -\
                                                                        -\
        ;--- Now output the standard heading bar -----------------      -\
        <$BsdHeadingBar TEXT=^{$Text=^Branch Systems Development^}^>
#define BsdHeadingBar                                                    \
        ;--- Put Heading of page into a TABLE --------------------      -\
        <$HtmlDebugNL>                                                  -\
        <$HtmlDebugComment TEXT="Start of Heading Bar">                 -\
        <TABLE WIDTH=100% BORDER=0                                       \
               BGCOLOR=<$BsdColorBgTitleAndNavigation>                   \
               CELLSPACING=0 CELLPADDING=5                              -\
        >                                                               -\
        <$HtmlDebugNL>                                                  -\
        <$RexxConcat>                                                   -\
        <TR>                                                            -\
           ;--- All left hand images in one cell -------                -\
           <$HtmlDebugComment TEXT="All right hand images into 1 cell"> -\
           <TD ALIGN=LEFT>                                              -\
           <TABLE BORDER=0 CELLSPACING=0                                 \
                  CELLPADDING=1  ;;Set Image spacing                    -\
           >                                                            -\
           <TR>                                                         -\
               ;--- Link To Intranet home page --------------           -\
               <$HtmlDebugComment TEXT="Go to Intranet Homepage">       -\
               <TD ALIGN=LEFT>                                          -\
                   <A HREF="<$IntranetHomePage>" TARGET=_top>           -\
                   <$IntranetImgHeaderbnz>                              -\
                   </A>                                                 -\
               </TD>                                                    -\
               <$RexxConcat>                                            -\
                                                                        -\
               ;--- Link To BSD home page --------------                -\
               <$HtmlDebugComment TEXT="Go to BSD Homepage">            -\
               <TD ALIGN=LEFT>                                          -\
                   <A HREF="<$BsdHomePage>" TARGET=_top>                -\
                   <$BsdImgBsdHome>                                     -\
                   </A>                                                 -\
               </TD>                                                    -\
               <$RexxConcat>                                            -\
                                                                        -\
           ;--- End of left hand images TABLE ----------                -\
           <$HtmlDebugNL>                                               -\
           </TABLE>                                                     -\
           </TD>                                                        -\
                                                                        -\
           ;--- Output title of this page ---------------               -\
           <$HtmlDebugComment TEXT="Title of this page">                -\
           <TD ALIGN=MIDDLE><FONT COLOR=<$BsdColorFgTitle>               \
               SIZE={$FONTSIZE="+2"}                                    -\
           >                                                            -\
               <B><CENTER><STRONG>                                      -\
               {$Text=^Branch Systems Development^}                     -\
               </STRONG></CENTER></FONT></B>                            -\
           </TD>                                                        -\
           <$RexxConcat>                                                -\
                                                                        -\
           ;--- All right hand images in one cell -------               -\
           <$HtmlDebugComment TEXT="All right hand images into 1 cell"> -\
           <TD ALIGN=RIGHT>                                             -\
           <TABLE BORDER=0 CELLSPACING=0                                 \
                  CELLPADDING=1  ;;Set Image spacing                    -\
           >                                                            -\
           <TR>                                                         -\
               ;--- Link to search for phone number ---------           -\
               <$HtmlDebugComment TEXT="Link to Intranet Phone Search"> -\
               <TD>                                                     -\
                   <A HREF="<$IntranetPhoneSearchPage>" TARGET=_top>    -\
                      <$IntranetImgHeaderPhone>                         -\
                   </A>                                                 -\
               </TD>                                                    -\
               <$RexxConcat>                                            -\
                                                                        -\
               ;--- Link to Site Information ----------------           -\
               <$HtmlDebugComment TEXT="Link to Intranet Site Info">    -\
               <TD>                                                     -\
                   <A HREF="<$IntranetSiteInfoPage>" TARGET=_top>       -\
                   <$IntranetImgHeaderSiteInfo>                         -\
                   </A>                                                 -\
               </TD>                                                    -\
               <$RexxConcat>                                            -\
                                                                        -\
               ;--- Link to search Engine -------------------           -\
               <$HtmlDebugComment TEXT="Link to Intranet Search">       -\
               <TD>                                                     -\
                   <A HREF="<$IntranetSiteSearchPage>" TARGET=_top>     -\
                   <$IntranetImgHeaderSiteSearch>                       -\
                   </A>                                                 -\
               </TD>                                                    -\
               <$RexxConcat>                                            -\
                                                                        -\
           ;--- End of right hand images TABLE ----------               -\
           <$HtmlDebugNL>                                               -\
           </TABLE>                                                     -\
           </TD>                                                        -\
                                                                        -\
        ;--- End of Heading Row/Table -------------------               -\
        </TR>                                                           -\
        </TABLE>                                                        -\
        <$HtmlDebugNL>                                                  -\
        <$HtmlDebugNL>
#define Title                                                            \
        {$Rule="<P><HR>"}                                               -\
        #if  ['{$ID=''}' <> '']                                         -\
             <A NAME="{$ID=''}"></A>    ;;User wants to name this posn  -\
        #endif                                                          -\
        <CENTER><H2><FONT COLOR=<$BsdColorBgTitleAndNavigation>>        -\
        {$Text}                                                         -\
        </FONT></H2></CENTER>

The following show how one of the macros could be used to generate a title in HTML:

<$TitleHtml Text=^The Title of the Page^ FONTSIZE=^+2^>

The following shows how one of the macros could be used to generate a title in a REXX CGI script (needs to be written to stdout):

/*--- Get dummy title (set up at compile - of rexx source - time) ---*/
#define+   RexxAssignTo    NewLineVar
NewLineVar = '<$TitleHtml Text=^$DUMMY$^ FONTSIZE=^+2^>';

/*--- Convert to real title and output (done at CGI runtime) --------*/
NewLineVar = ReplaceString(NewLineVar, '$DUMMY$', RealTitle);
say NewLineVar;

Note that the ReplaceString() used above is not PPWIZARD's, as of course at runtime it is unavailable. My website contains the source code for this and many other handy routines.


email me  any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Search][Prev]: Resource Validation - Local[Next]: TEXTEDIT with PPWIZARD


PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Sunday November 05 2017 at 10:00am