;---------------------------------------------------------------------------- ; MODULE NAME: HTMLPRE.IH ; ; $Author: Dennis_Bareis $ ; $Revision: 1.0 $ ; $Date: 15 Mar 1999 17:33:08 $ ; $Logfile: E:/DB/PVCS.IT/OS2/PPWIZARD/HTMLPRE.IHV $ ; ; DESCRIPTION: This is a header file for handling inclusion of ; "examples" into HTML. ; ; See PPWIZARD documentation for examples of this file ; in use. The sample "TryMe.IT" file also uses this ; header file. ; ; ; Macro "ExampleFile" ; ~~~~~~~~~~~~~~~~~~~ ; ; This macro takes the following parameters: ; ; FILE ; ~~~~ ; Manditory. Identifies the file to be included. ; ; FRAGMENT ; ~~~~~~~~ ; Optional. You may wish to have a single example ; file hold more than one example. The text that ; you supply for this parameter marks the line before ; as well as the line after the example. ; ; ; INDENT ; ~~~~~~ ; Optional. By default a 4 space indent is used, ; you specify the number of spaces with 0 being ; valid. ; ; STATE ; ~~~~~ ; Optional. By default no autotagging will be ; performed. If you specify "REMEMBER" then the ; currently available autotags will be used, you ; may also specify which states tags should come ; from (see the "#AutoTagState +" command). ; ; ; ASIS ; ~~~~ ; Optional. By default only basic "AsIs" tagging ; is performed. If for example you wished to ; handle international characters then you would ; need to specify the names of the AsIs tags to use. ; ; ; ; Macro "Example / eExample" ; ~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Note that your "inline" example code must not contain ; a reference to the macro "eExample" as this is used ; internally. ; ; This macro takes the following parameters: ; ; ; INDENT ; ~~~~~~ ; As above. ; ; STATE ; ~~~~~ ; As above. ; ; ; ASIS ; ~~~~ ; As above. ; ; ; ;---------------------------------------------------------------------------- ;--- Define the version number of this header file -------------------------- #define VERSION_HTMLPRE_IH 99.047 ;---------------------------------------------------------------------------- ;--- Set up defaults that user can override --------------------------------- ;---------------------------------------------------------------------------- #ifndef HTMLPRE_COLOR #define HTMLPRE_COLOR purple #endif #ifndef HTMLPRE_STYLE_OTHER #define HTMLPRE_STYLE_OTHER ;font-size:80% #endif ;--- Define some aliases for characters we need to be careful with ---------- #RexxVar "LT" =x= "<" ;;'<' Char #RexxVar "GT" =x= ">" ;;'>' Char #RexxVar "AMP" =x= "&" ;;'&' Char #RexxVar "HASH" =x= "#" ;;'#' Char ;--- Define look and feel of examples --------------------------------------- #define ExampleFormatted \ > ;;Set up font (older browsers) -\
    #define eExampleFormatted                                                                           \
            
-\
;;Restore Font (older browsers) ;--- Set up AsIs Mode (minimum changes required - user can add to these) ---- #AutoTagState + ;--- Define characters that should be automatically modified ------------- #AutoTag "<" "" #AutoTag "&" "" #AutoTag "#" "" ;--- "PROGRAM" ASIS mode ------------------------------------------------- #AsIs SETUP HTMLPRE_IH #AutoTagState - ;---------------------------------------------------------------------------- ;--- EXAMPLE FILE INCLUSION ------------------------------------------------- ;---------------------------------------------------------------------------- #define ExampleFile \ <$ExampleFormatted> -\ #AutoTagState + {$STATE=''} ;;User can set up own tags -\ #option PUSH ExtraIndent=^copies(' ', {$Indent='4'})^ -\ #AutoTag ON -\ #AsIs ON HTMLPRE_IH {$AsIs=''} -\ #include "{$File}" "{$Fragment=''}" -\ #AsIs OFF -\ #option POP -\ #AutoTagState - -\ <$eExampleFormatted> ;---------------------------------------------------------------------------- ;--- EXAMPLE (INLINE) ------------------------------------------------------- ;---------------------------------------------------------------------------- #define Example ;;Starts Example \ <$ExampleFormatted> -\ #AutoTagState + {$STATE=''} ;;User can set up own tags -\ #option PUSH ExtraIndent=^copies(' ', {$Indent='4'})^ -\ #option PUSH replace=OFF -\ #AutoTag '$eExample>' '<$eExample>' #1 -\ #option POP ;;Restore REPLACE mode -\ #AutoTag ON -\ #AsIs ON HTMLPRE_IH {$AsIs=''} -\ #define HTMLPRE_INLINE_EXAMPLE #define eExample ;;Ends Example \ #ifndef HTMLPRE_INLINE_EXAMPLE -\ #error ^Incorrectly formatted inline example (can't include end of example tag)^ -\ #endif -\ #AsIs OFF -\ #option POP -\ #AutoTagState - -\ #undef HTMLPRE_INLINE_EXAMPLE -\ <$eExampleFormatted> This is the source for this page: ;--- Common start ----------------------------------------------------------- #include "PPWIZARD.IH" ;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

THE BASICS

This preprocessor can be used to generate HTML (and rexx or other) code from source files. It supports commands such as "#include", "#define", "#if" and much more.

Just from the commenting point of view, PPWIZARD comments are much easier to use than html ones and blank lines and leading spaces on lines are removed (by default) so that you can space out or indent your html as much as you like but the generated html is compact and fast to download (and people don't see your comments unless you want them to).

I maintain two differing homepages (this is one of them) from the same source, all the html you are seeing has been processed/generated by this program. Note that the '#if' processing is very powerful and that you can execute any rexx commands and use the output (all the file sizes and dates where provided were automatically calculated by this program). The #define command supports parameters and conditional generation of code.

PPWIZARD has a text to html mode. Unlike other tools PPIZARD can easily add standard features such as background, standard headers and footers (the look and feel of your site). It will create hypertext links where possible (by default). If you have any ideas or issues with the initial implementation then be sure to tell me.

As a rexx preprocessor it allows you to easily create header files of standard routines so that you never need to duplicate source code again! I have made some <$A_Db$FreeWareDesc_REXX_HEADERS>source routines available for #include in your programs. Rexx code is packed by default so that your input can contain many comments and be spaced out with most of this being removed from your runtime.

Note that this program can be used for virtually any file type and not just html & rexx. ;** CommentBlock /* (Thursday 04/02/1999, 22:25:29, by Dennis_Bareis) */ ;**+-------------------------------------------------------------------------- ;**|Some people use PPWIZARD macros to develop ;**|<$ExtHttp HTTPURL="<$HttpWebWriter>" VISIBLE=^AWE^> ;**|(binary) def files and someone uses it with PHP. ;**+-------------------------------------------------------------------------- ;** /* (Thursday 04/02/1999, 22:25:29, by Dennis_Bareis) */

Java Script header files for common routines is another possibility. The point is you should never duplicate something, if at all possible only define an item once and reuse it. If you have made a mistake or need to change it then this change can be made in one place and the output regenerated. ;############################################################################## ;### Automatically link examples to online doco. This gets a little bit ### ;### complicated because of some of the automatic filename generation that ### ;### occurred during the generation of the doco as well as the fact that ### ;### a '#' is 'invalid' in a URL filename. ### ;############################################################################## #define ExampleLinkToPpw#Same \ #evaluate+ '' ^PpwUrl = ToLowerCase("ppwizard/{$Name}.htm")^ -\ {$Name} #define ExampleLinkToPpw#Cmd \ #if '{$Url=''}' <> '' -\ #RexxVar PpwUrl = 'ppwizard/{$Url}.htm' -\ #elseif -\ #evaluate+ '' ^PpwUrl = ToLowerCase("ppwizard/hash" || strip(substr('{$CMD}', 9)) || ".htm")^ -\ #endif -\ {$CMD} ;;Generate link #AutoTag "AsIs" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "import" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "evaluate" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "AutoTag " ^<$ExampleLinkToPpw#Cmd CMD="{$AT}"> ^ #AutoTag "AutoTagState" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "include" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "define" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "undef" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "option" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "RexxVar" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "info" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "ifndef" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "elseif" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "endif" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "error" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "break" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "DependsOn" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}">^ #AutoTag "{" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}" URL="loopstart/index.html">^ #AutoTag "}" ^<$ExampleLinkToPpw#Cmd CMD="{$AT}" URL="loopend/index.html">^ #AutoTag "if " ^<$ExampleLinkToPpw#Cmd CMD="if"> ^ #AutoTag "ToLowerCase" ^<$ExampleLinkToPpw#Same NAME="{$AT}">^ #AutoTag "GetImageHeightWidth" ^<$ExampleLinkToPpw#Same NAME="{$AT}">^ #AutoTag "ExtraIndent" ^<$ExampleLinkToPpw#Same NAME="{$AT}">^ ;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

EXAMPLE - SIMPLE BEGINNING

PPWIZARD allows you to <$Bold Text="name"> things, these items (if required in more than one html page) would typically be placed into a seperate "header" file which all pages include.

Assume we have the following lines in the file "HEADER.IH": <$ExampleFile STATE="REMEMBER" FILE="PPWEXAMP.IH" FRAGMENT="SimpleStartHeader" AsIs=^DANGEROUS^>

The you could refer to the header definitions in one of your pages with: <$ExampleFile STATE="REMEMBER" FILE="PPWEXAMP.IH" FRAGMENT="SimpleStartCode">

Note that there is a single place to make a change if the site moves, you don't have to hunt through all your html files.

It is no accident that the #include, #define and other PPWIZARD have pretty much the same syntax as as that used for the 'C' language. This allows header files to be shared. I share PPWIZARD header files between 'C', rexx, html and CGI programs (for example for common html headers and footers).

Being able to do basic manipulation of html effectively on the 'client' side can improve overall server performance. The basic functions of PPWIZARD can frequently do the same things that a lot of people use Server Side Includes (SSI) and CGI code to solve. Note that for more advanced functionality nothing will beat server side coding - but why use it unless you have to? PPWIZARD can be run (and is being run) on the server using its /CGI mode however you'd need to examine its performance in this environment. ;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

EXAMPLE - IMPORT COMMA SEPERATED FILE

Assume that we have a file called "PPWEXAMP.CSV" which has been produced by Microsoft's EXCEL or 123: <$ExampleFile STATE="REMEMBER" FILE="PPWEXAMP.CSV">

Then with the following code you could import the file and generate a HTML table: <$ExampleFile STATE="REMEMBER" FILE="PPWEXAMP.IH" FRAGMENT="AllDefaultTable">

You would get the following table generated:

#include "PPWEXAMP.IH" "AllDefaultTable"

To obtain a slight fancier and reorganised table you could use: <$ExampleFile STATE="REMEMBER" FILE="PPWEXAMP.IH" FRAGMENT="FancierTable">

The following generated table has cyan heading and fields reordered:

#include "PPWEXAMP.IH" "FancierTable"

To drop the email address field and make the home page address a hypertext link you could use: <$ExampleFile STATE="REMEMBER" FILE="PPWEXAMP.IH" FRAGMENT="FancierTableWithLinks">

The new table looks like:

#undef IMPORT_HEADING_COLUMNS #undef IMPORT_TABLE_ATTRIBS #include "PPWEXAMP.IH" "FancierTableWithLinks"

As you can see from the above it is fairly simple to perform some quite complex table setups including the dropping or reordering of fields. For more complex requirements (or to define your own import format) you can make use of macros. You can also automatically modify table entries such that "High" gets converted to "H" etc.

Another point I should make is that you are not restricted to HTML tables, if you were generating an OS/2 IPF file you could generate an IPF table, or in fact for all file types you don't need to generate a table at all (the HTML table is simply the default format).

You might have noticed the use of a "#define" in the above code, if you were preprocessing "C" code this would probably be an issue to you as you would probably not want PPWIZARD to process standard header files such as "stdio.h". PPWIZARD has many options which allow it to get out of the way in all of its processing, for example you can make PPWIZARD use the "!include" command and ignore "#include". ;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

EXAMPLE - DATABASE SQL

PPWIZARD does not support SQL directly but it doesn't need to as it can interface to any database if a rexx interface is available. This example makes use of a free product by <$ExtMail EMAIL="[email protected]" VISIBLE="Mark Hessling"> called <$Red Text="RexxSQL">. It is available from "<$ExtHttp HTTPURL="<$HttpFreeRexxSQLByMarkHessling>" VISIBLE='<$HttpFreeRexxSQLByMarkHessling>'>".

RexxSQL can access a large number of database programs accross a number of operating systems. The following example was tested on the free <$Red Text="mSQL"> database program. <$ExampleFile STATE="REMEMBER" FILE="PPWEXAMP.IH" FRAGMENT="mSqlExample"> ;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

EXAMPLE - COMPLEX MACRO

This example shows how I simplify some of my photo pages, I do not need to know image sizes etc although I do want my generated HTML to contain them for improved browser performance. The image sizes are obtained from local copies I maintain (the source), my macro knows where they are. The macro has been written in a way that allows you to specify an alternative size if you wish to.

The following code defines a photo macro (could be done in seperate header file) and then creates a table and uses the macro: <$ExampleFile STATE="REMEMBER" FILE="PPWEXAMP.IH" FRAGMENT="PhotoExample">

The following table is generated by the above code:

#include "PPWEXAMP.IH" "PhotoExample" ;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

EZine TUTORIAL/EXAMPLES

The following installments of e-Zine! articles are available, they start from the absolute basics to quite a good implementation of a simple online store:

    #if <$AtHome> ;--- Can make external links to internet pages -----------------------
  1. <$ExtHttp HTTPURL="<$HttpMagazineOs2Ezine>/v3n05/htmlpp1.htm" VISIBLE=^Building Dynamic Web Sites Part 1^>
  2. <$ExtHttp HTTPURL="<$HttpMagazineOs2Ezine>/v3n06/htmlpp.htm" VISIBLE=^Building Dynamic Web Sites Part 2^>
  3. <$ExtHttp HTTPURL="<$HttpMagazineOs2Ezine>/v3n12/dyn3.htm" VISIBLE=^Building Dynamic Web Sites Part 3^>
  4. <$ExtHttp HTTPURL="<$HttpMagazineOs2Ezine>/v3n14/dws.htm" VISIBLE=^Building Dynamic Web Sites Part 4^>
  5. <$ExtHttp HTTPURL="<$HttpMagazineOs2Ezine>/v4n3/dws.htm" VISIBLE=^Building Dynamic Web Sites Part 5 - Widgets & Macros^> #elseif ;--- No access to internet is available ------------------------------
  6. Building Dynamic Web Sites Part 1
  7. Building Dynamic Web Sites Part 2
  8. Building Dynamic Web Sites Part 3 #endif
;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

EXAMPLE - SOME OF THIS PAGES SOURCE CODE

I will show you some of the main files for this page. I do not pretend that what you will see is the best way to do something, its just here to give you a better idea of what can be done. Note that I use the "ExtHTTP" macro to ensure that the version of my web pages that I install on my work's intranet have no external links.

This is a header file "HTMLPRE.IH" (comes with PPWIZARD) that allows me to automatically include real working code as an example on this page (note that not all of its features are used by this page): <$ExampleFile STATE="REMEMBER" FILE="HTMLPRE.IH"> ;--- Need to copy file before #include as file inclusion of "self" causes file closure (therefore infinite loop) ---

This is the source for this page: #evaluate '' 'call AddressCmd "copy PPWIZARD.IT OUT\PPWIZARD.IT >nul"' <$ExampleFile STATE="REMEMBER" FILE="OUT\PPWIZARD.IT" AsIs=^DANGEROUS^> ;;Can't include myself as file closed at end ;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

HELP MAKE PPWIZARD BETTER

Note that a lot of work has gone into PPWIZARD (as you can probably guess from even a quick look at its capabilities). I would probably make money selling it (and many people tell me I should) but I'm happy to make it and my many other tools freely available. All I ask in return is feedback (good or bad) and to be told about any problems in its use (ppwizard bugs or otherwise). Being a generic tool I may not have thought about all possible uses or situations this tool can be used in, this makes your feedback valuable. Future changes will concentrate in areas for which I have received user feedback.

When reporting problems along with all relevant information please supply the redirected output from the ppwizard command when executed with the "/debug" switch.

If you continue to use PPWIZARD then could you please consider telling all your friends and linking to this page! You can use the following icon if you wish:

<$ImgMadeWithPpwizard>

The above icon is not bad, can anyone do better for a 100xWhatever low bandwidth "Made with PPWIZARD" or similar icon. I'll give you a free copy of PPWIZARD :-). ;############################################################################## ;############################################################################## ;############################################################################## <$ImgBarbedWire>

ALTERNATIVES

OK you are either not convinced or you don't like PPWIZARD, here are the alternatives that I know of (in order of apparent power - to me):

  1. <$ExtHttp HTTPURL="www.imatix.com/html/htmlpp/">
    HTMLPP, a free perl based preprocessor, like PPWIZARD it can be extended.

  2. <$ExtHttp HTTPURL="www.cinenet.net/users/cberry/orbinfo.html">
    ORB, simple preprocessor with cryptic syntax.

  3. <$ExtHttp HTTPURL="www.crl.com/~jnelson/htp/">
    HTP, simple free preprocessor with cryptic syntax.

I put the above links here so you can compare my product with others before making a decision. I know how hard it is to find these sorts of products from when I was looking around (before I decided I had to write my own). Any of these products would be better than coding "straight" html. ;--- Thats All -------------------------------------------------------------- <$MadeWithWarpPlusModifiedTime>