PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
#import - Delimited Records
This type of #Import has clearly defined fields.
You would frequently wish to display these in a table (say in
a HTML page) however nothing says that you need to do so.
If you wish to create macros and
then #include a template file then that is also possible.
Within a record the fields are delimited by a single character such as
a tab or comma.
Note that under Windows you have the option of reading these sorts
of files via ODBC and therefore you can use an
SQL import!
This gives you greater control without extra coding such as controlling
sorting the data or only choosing records that match certain criteria
(as per normal SQL query syntax).
Field Information Parameters
On these types of imports "FieldInfo" followings
the "DefineName" parameter.
You must specify field information for each field up to the
last one you are interested in.
The field information is of the format:
[{NewColumn}]TitleText
The optional "NewColumn" specifies the column you wish the
field to be moved to. This need only be supplied if you wish to
change the order, by default the first field is column 1 etc.
The "title text" specifies the value for the field in the
header record. A blank "title" is used to indicate that we
don't require a field and it should be dropped.
DEFINITIONS/OPTIONS
If you can't understand how these options work then I suggest
you try using /debug or #debug to
watch what variables the import uses etc.
- DefineName_BLANK_FIELD
Normally a blank field will be displayed as blank.
You may wish to display '-' instead.
Another possiblity is to display a 1 by 1 transparent gif so as
to have table borders around blank fields look better.
For even more control (probably rare requirement):
- DefineName_BLANK_COLUMN_?
This allows you to specify different blank replacement
values for each column.
- DefineName_DROP_BLANK_LINES
You can specify whether or not blank lines (or lines where all fields are blank) are significant. The default is 'Y' to drop blank lines, specify 'N' to prevent this.
- DefineName_NEWLINE_CHAR
This can be used to determine what newlines within fields should be
replaced with ("
" by default).
- DefineName_TAB_CHAR
Normally tabs are ignored by the import process. This variable allows you to replace them with something else.
- DefineName_ASIS_TAGGING
This option can be used to adjust the conversion of what may be problem characters (such as '<' in HTML). By default
importing does not handle/convert international characters such as umlauts to html symbols but there is nothing preventing you from doing so.
This definition lists zero, one or more names as used on previous "#AsIs SETUP" commands (seperated by whitespace). Clear this definition to prevent all ASIS conversions.
Note that you will probably need to override this value (maybe others as well) if you wished to expand any macros
that the imported data might contain (by default this is not done).
- DefineName_DROP_LINE_COUNT
If we are dropping lines (TAB- command etc), then how many should be
dropped. The default is one.
- DefineName_BEFORE
You would probably only use this define if you didn't want to
generate a table at all. You may specify the string
"{$Columns}" which will get replaced with the number of
fields to be displayed.
If this define is not used then you can use the following:
- DefineName_TABLE_ATTRIBS
This value allows you to specify all HTML attributes of the
table apart from the number of columns.
- DefineName_HEADER
This is used to control the "code" which handles the "heading" record,
this does not have to be a html table.
You can specify the string {$Column?} to
represent a fields value (? = number of field where 1 is the first).
If this define is not used then you can use the following:
- DefineName_HEADING_COLUMNS
This value allows you to specify the column (HTML "<TH>" tags)
information to change alignment or colours of columns.
This value becomes the default for all columns.
- DefineName_HEADING_COLUMN_?
This value allows you to specify the column (HTML "<TH>" tags)
information to change alignment or colours of specific columns.
Another use for this would be to specify the width of a column.
This value is only used for column number '?'.
- DefineName_HEADING_BEFORE_DATA
This value allows you to specify some text to be placed in front
of the fields data, for example if you wish to change the font size
for each column you might used the value
"<FONT SIZE=-1>".
This value becomes the default for all columns.
- DefineName_HEADING_BEFORE_DATA_?
This value allows you to specify leading data on a column by
column basis.
- DefineName_HEADING_AFTER_DATA
This value allows you to specify some text to be placed after
the fields data, for example if you wish to change the font size
for each column you might used the value
"</FONT>" to close the previous font tag.
This value becomes the default for all columns.
- DefineName_HEADING_AFTER_DATA_?
This value allows you to specify trailing data on a column by
column basis.
- DefineName_RECORD
This is used to control the "code" for each record,
this does not have to be a html table.
You would definately define this option if you didn't want a html
table, you might wish to create s series of #defines or maybe you are
not generating html at all and need to generate an IPF table.
You can specify the string {$Column?} to
represent a fields value (? = number of field where 1 is the first).
If this define is not used then you can use the following:
- DefineName_RECORD_COLUMNS
This value allows you to specify the column (HTML "<TD>" tags)
information to change alignment or colours of columns.
This value becomes the default for all columns.
- DefineName_RECORD_COLUMN_?
This value allows you to specify the column (HTML "<TD>" tags)
information to change alignment or colours of specific columns.
Another use for this would be to specify the width of a column.
This value is only used for column number '?'.
- DefineName_RECORD_BEFORE_DATA
This value allows you to specify some text to be placed in front
of the fields data, for example if you wish to change the font size
for each column you might used the value
"<FONT SIZE=-1>".
This value becomes the default for all columns.
- DefineName_RECORD_BEFORE_DATA_?
This value allows you to specify leading data on a column by
column basis.
- DefineName_RECORD_AFTER_DATA
This value allows you to specify some text to be placed after
the fields data, for example if you wish to change the font size
for each column you might used the value
"</FONT>" to close the previous font tag.
This value becomes the default for all columns.
- DefineName_RECORD_AFTER_DATA_?
This value allows you to specify trailing data on a column by
column basis.
- DefineName_AFTER
Unless you are not creating a table you are unlikely to want to
change the codes that end the table.
- DefineName_RECORD_FILTER
The contents of this variable should be one or more
rexx expressions.
Normally all records are displayed.
A filter can examine all column variables and modify them or tell
PPWIZARD to ignore the record. The filter is not called for
the heading record.
The following rexx variables and functions are relevant:
- Remove
If this variable is set to any non blank value then
the record will be dropped, the variables value is
shown when debugging so it is recommended that the
value be the reason for dropping the record.
If the contents starts with 'EOF:' then the current
record and ALL following are dropped.
- Column.?
The "Column" array holds the data for each field (that you
are interested in) of the current record in the order you
provided. For example "Column.2" holds the 2nd column's
data.
Note that "Column.0" holds the number of fields in the array.
- Dropped.?
The "Dropped" array holds the data for each field (that you
dropped) of the current record in the order that they were
dropped. For example "Dropped.1" holds the first dropped
field.
Note that "Dropped.0" holds the number of fields in
the array.
- ThisRecordsCodes
This variable gets initialized for each record with the
value that you defined (or allowed to default) for the
"DefineName_RECORD"
option. You can add to or modify this record in any way.
The value of "{$Column1}" gets replaced with the contents
of the rexx variable "Column.1" etc.
If all your records are processed the same way then you
should not need to modify this variable. It is useful where
you might want the output (row of table) to look different
depending on the records data. In some cases this can
be better done by updating the rexx "Column.?" array.
If you need multiple lines you can of course use
"<?NewLine>" where required.
- WriteLineToTmpImportFile()
The passed data is written to the output file, any line
feed characters will indicate the end of a line.
- RecordFilter
If you don't need to do any more filtering then you can
clear this variable. This will improve performance.
- DefineName_KEEP_TMP_FILE
Normally PPWIZARD keeps the temporary file it creates while
importing when debug is on.
This option allows you to specify whether you do or don't
want the file kept (whether debug is on or off).
- DefineName_DO_PASS_2
You would rarely wish to modify this value.
It controls whether or not the generated file is #included
(pass 2), it's value defaults to 'Y'.
You might wish to disable the processing if all your processing can
be done in pass one (for example you have imported a database into
memory.
- DefineName_PROTECT_START
By default will be set to the value
<?ProtectFromPpwStart>.
If you have filter code that wants to generate PPWIZARD commands
then you will need to override this value. Have a look at the
multiple HTML pages
example.
- DefineName_PROTECT_END
By default will be set to the value
<?ProtectFromPpwEnd>.
You should also check out an example of importing a file into
multiple HTML pages based
on the contents of one of the fields.
Examples - Comma Delimited
A tab delimited file is probably be best format to use however
this example will use comma delimited as its a bit hard to display a
tab! Assume the following file is being imported (Importme.CMA):
Dennis,Bareis,Programmer
Wendy,Buxton,Librarian
Fred,Nerk,Idiot
Please treat each of the following examples in isolation and
assume that no #defines other than those specifically
shown for that example have been set. Please note that I
could have used ",,," instead of "CMA" when specifying the format.
The following code will display the 3 fields in the order they occur (in
a completely default table format):
#import IMPORTME.CMA "CMA" '' "First Name" "Last Name" "Job"
We now wish to simply swap the order of the "Job" column so it
becomes first:
#import IMPORTME.CMA CMA '' "{2}First Name" "{3}Last Name" "{1}Job"
Lets drop the last name altogether so that we only see the first
name and job columns:
#import IMPORTME.CMA CMA '' "First Name" "" "Job"
Lets display the above table using slightly different table
formatting (column borders thinner, table border fatter, headings
centered on yellow background and record data left justified):
#define IMPORT_TABLE_ATTRIBS BORDER=20 CELLSPACING=1
#define IMPORT_HEADING_COLUMNS ALIGN=CENTER BGCOLOR=YELLOW
#define IMPORT_RECORD_COLUMNS ALIGN=LEFT
#import IMPORTME.CMA CMA '' "First Name" "" "Job"
As above but column 2 is centered:
#define IMPORT_TABLE_ATTRIBS BORDER=20 CELLSPACING=1
#define IMPORT_HEADING_COLUMNS ALIGN=CENTER BGCOLOR=YELLOW
#define IMPORT_RECORD_COLUMNS ALIGN=LEFT
#define IMPORT_RECORD_COLUMN_2 ALIGN=CENTER
#import IMPORTME.CMA CMA '' "First Name" "" "Job"
Examples - More Complex
This example is based on a real one situation at work. We export
date from Microsoft's access/Excel and want this data to appear
in a table.
The following main points are demonstrated:
- The use of #defines and line continuation to format
things to be easier to read and understand.
- The use of #autotag to translate some
of the text (for example "priority") to minimize the width of the
columns.
- More complex overriding of defaults to get smaller font size etc.
- More field dropping but also swapping of fields.
<HTML>
;--- Problem database data exported from Excel (trying from access) ---------
<CENTER><H1>Release 98.0.1</H1></CENTER>
;--- Setup table definitions ------------------------------------------------
#define IMPORT_TABLE_ATTRIBS BORDER=5 CELLSPACING=1
#define IMPORT_BLANK_FIELD -
;** CommentBlock /* (Tuesday 23/06/1998, 13:00:55, by Dennis_Bareis) */
;**+--------------------------------------------------------------------------
;**|#define IMPORT_HEADING_COLUMNS ALIGN=CENTER BGCOLOR=YELLOW
;**|#define IMPORT_RECORD_COLUMNS ALIGN=CENTER
;**|#define IMPORT_RECORD_COLUMN_2 ALIGN=LEFT
;**|#define IMPORT_RECORD_COLUMN_4 ALIGN=LEFT
;**+--------------------------------------------------------------------------
;** /* (Tuesday 23/06/1998, 13:00:55, by Dennis_Bareis) */
;--- Define some data translations (shorten Priority + Problem Type) --------
#AutoTag ">High<" ">H<"
#AutoTag ">Low<" ">L<"
#AutoTag ">Medium<" ">M<"
#AutoTag ">Change<" ">C<"
#AutoTag ">Error<" ">E<"
;--- Try these --------------------------------------------------------------
#define IMPORT_HEADER <TR> -\
<TH ALIGN=CENTER BGCOLOR=YELLOW><FONT SIZE=-1>{$Column1} -\
<TH ALIGN=CENTER BGCOLOR=YELLOW><FONT SIZE=-1>{$Column2} -\
<TH ALIGN=CENTER BGCOLOR=YELLOW><FONT SIZE=-1>{$Column3} -\
<TH ALIGN=CENTER BGCOLOR=YELLOW><FONT SIZE=-1>{$Column4} -\
<TH ALIGN=CENTER BGCOLOR=YELLOW><FONT SIZE=-1>{$Column5} -\
<TH ALIGN=CENTER BGCOLOR=YELLOW><FONT SIZE=-1>{$Column6} -\
<TH ALIGN=CENTER BGCOLOR=YELLOW><FONT SIZE=-1>{$Column7} -\
<TH ALIGN=CENTER BGCOLOR=YELLOW><FONT SIZE=-1>{$Column8} -\
</TR>
#define IMPORT_RECORD <TR> -\
<TD ALIGN=CENTER><FONT SIZE=-1>{$Column1} -\
<TD ALIGN=LEFT><FONT SIZE=-1>{$Column2} -\
<TD ALIGN=CENTER><FONT SIZE=-1>{$Column3} -\
<TD ALIGN=LEFT><FONT SIZE=-1>{$Column4} -\
<TD ALIGN=CENTER><FONT SIZE=-1>{$Column5} -\
<TD ALIGN=CENTER><FONT SIZE=-1>{$Column6} -\
<TD ALIGN=CENTER><FONT SIZE=-1>{$Column7} -\
<TD ALIGN=CENTER><FONT SIZE=-1>{$Column8} -\
</TR>
;--- Specify the fields -----------------------------------------------------
#define FIELD_NAMES "{1}Problem<BR>#" \
"{2}Title" \
"{5}P<BR>r<BR>i" \
"{8}Pre<BR>/<BR>Spar" \
"{6}T<BR>y<BR>p<BR>e" \
"{3}Application" \
"" \
"" \
"{7}Fixed By" \
"" \
"" \
"" \
"" \
"" \
"{4}User Impact"
;--- Make the changes (autotag some text) -----------------------------------
#AutoTag ON
#import "export.tab" TAB- "" <$FIELD_NAMES>
#AutoTag OFF
</HTML>
Examples - IPF Import
The following code:
#define IMPORT_NEWLINE_CHAR <?NewLine>.br<?NewLine>
#define IMPORT_BEFORE :table cols='15 15 10'.
#define IMPORT_HEADER :row. -\
:c.:hp9.{$Column1}:ehp9. -\
:c.:hp9.{$Column2}:ehp9. -\
:c.:hp9.{$Column3}:ehp9.
#define IMPORT_RECORD :row. -\
:c.{$Column1} -\
:c.{$Column2} -\
:c.{$Column3}
#define IMPORT_AFTER :etable.
#define IMPORT_RECORD_COLUMNS ALIGN=LEFT
#import "EXAMPLE.CMA" CMA '' "First Name" "Surname" "Job"
Example - Use of Filter
#DefineRexx IMPORT_RECORD_FILTER
if Column.1 = "Wendy" then
Remove='This is "Wendy" record' ;;Don't want this record
else
Column.1 = translate(Column.1) ;;Make column #1 upper case
#DefineRexx
#import ImportMe.CMA CMA "" "First<BR>Name" "Surname" "Job"
PPWIZARD Manual

Friday June 01 2001 at 5:58pm