PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: <?CTEXT.EXE>[Next]: <?DebugOn>
\ -> Standard Definitions -> <?Data>

<?Data:DataName.RowNumber[.ColumnNumber]>

This symbol provides a simple mechanism to retrieve the information previously saved using the #data command. The rexx function DataInfo() can also be used.

This command can return the following types of information:

  1. Whether or not the data exists. If it does where was it defined?
  2. The number of rows of data.
  3. The number of columns per row.
  4. The value for a specific column in a specific row.

The "DataName" parameter simply defines the name of #data collection.

The second and third parameters determine the type of query as follows (checked in order):

If the data can contain symbols requiring expansion then you probably need to use <?RestartLine> for the expansion to occur.

This is a Standard Definition which always exists (you don't need to #define it). Note that you can create your own variations or completely new ones (see the examples).

Example - #Import to a Table

In this example the data comes from a database (#import):

;--- Import the information (store in memory) ---
#NextId
#define IMPORT_#DATA TmpCsv    ;;Import to memory
#(
   #import "SomeCommaSeparatedFile.CSV" CMA ""
           "EmailAddress"      ;;CSV Field #1
           "Name"              ;;CSV Field #2
           "HomePage"          ;;CSV Field #3
#)

;--- Start a table and output heading line ------
<table border=1>
   <tr>
       <th>Name</th>
       <th>Email<br>Address</th>
       <th>Home<br>Page</th>
   </tr>

;--- Output the imported records ----------------
#{ FOR @@Record = 1 to <?Data:TmpCsv.?>
   ;--- Is this an EVEN or ODD row? -------------
   #if @@Record // 2 = 0      ;;Can use CSS (stylesheet) to alternate background color etc
       #define+ TrClass EVEN
   #elseif
       #define+ TrClass ODD
   #endif

   ;--- Start row (set class to "EVEN/ODD") -----
   <tr class='<$TrClass>'>
      ;--- Output Name --------------------------
      <td><?Data:TmpCsv.@@Record.2></td>

      ;--- Output email address -----------------
      <td><a href="mailto:<?Data:TmpCsv.@@Record.1>"><?Data:TmpCsv.@@Record.1></a></td>

      ;--- Output homepage ----------------------
      <td><a href="<?Data:TmpCsv.@@Record.3>" target="_blank"><?Data:TmpCsv.@@Record.3></a></td>
   </tr>
#}

;--- End the table ------------------------------
</table>

Example - #Data

In this example the data comes via the #data command:

;--- Define three rows ---
#data Fred 3
   ;--- Row 1 ---
   "1a" "1b" '1c'

   ;--- Row 2 ---
   #( ' '
       ~2a~
       @2b@
       /2c/
   #)

   ;--- Row 3 ---
   #if [1 = 1]
       '3a t' '3b t'    \
       "3c t"
   #elseif
       '3a f' '3b f'    \
       "3c f"
   #endif

   ;--- "import" some more rows ---
   #include "MoreRows.DB"
#data

;--- Use the values (PPWIZARD) ---
#if  ['<?Data:Fred>' = '']
   There is no #data structure called "Fred"!
#elseif
   There are <?Data:Fred.?> rows of data
   each with <?Data:Fred.*.?> columns.
   <?NewLine>
   "Fred" was defined at <?Data:Fred>.

   #{ FOR @@X = 1 to <?Data:Fred.?>
       <?NewLine>
       === Row <??@@X> of <?Data:Fred.?> ===
       <?Space>   * Col 1 = <?Data:Fred.@@X.1>
       <?Space>   * Col 2 = <?Data:Fred.@@X.2>
       <?Space>   * Col 3 = <?Data:Fred.@@X.3>
   #}
#endif


;--- Display the values (REXX) ---
#DefineRexx ''
   do  @@X = 1 to Fred.0
       call Say ''
       call Say '=== Row ' || @@X || ' of ' || Fred.0 || ' ==='
       call Say '   * Col 1 = ' || Fred.@@X.1
       call Say '   * Col 2 = ' || Fred.@@X.2
       call Say '   * Col 3 = ' || Fred.@@X.3
   end;
#DefineRexx

Example - #Import (one HTML page per record)

In this example the data comes from a database (#import):

;--- Import the information (store in memory) ---
#NextId
#define IMPORT_#DATA TmpCsv    ;;Import to memory
#(
   #import "SomeCommaSeparatedFile.CSV" CMA ""
           "EmailAddress"      ;;CSV Field #1
           "Name"              ;;CSV Field #2
           "HomePage"          ;;CSV Field #3
#)

;--- Create a HTML page per CSV record ---
#{ FOR @@Record = 1 to <?Data:TmpCsv.?>
   ;--- Collect Information to be passed to the #included file ---
   #define+ CSV_NAME    <?Data:TmpCsv.@@Record.2>
   #define+ CSV_EMAIL   <?Data:TmpCsv.@@Record.1>
   #define+ CSV_WEBPAGE <?Data:TmpCsv.@@Record.3>

   ;--- Now create the HTML page (inline - would normally use #include) ---
   #output "out\CSV_<$CSV_NAME>.htm" ASIS
       <html>
       <head>
           <title>BASIC page for "<$CSV_NAME>"</title>
       </head>
       <body>
           ;--- Heading ------------------
           <center><h1>BASIC page for "<$CSV_NAME>"</h1></center>

           ;--- Page body ----------------
           <p><$CSV_NAME> has an email address of "<$CSV_EMAIL>" and a
           web address of "<$CSV_WEBPAGE>".

           ;--- Footer -------------------
           <hr size=1 color=red>
           <center><?CompileTime><br><$CSV_NAME></center>
       </body>
       </html>
   #output
#}


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

[Top][Contents][Search][Prev]: <?CTEXT.EXE>[Next]: <?DebugOn>


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