PowerSurge Publishing

 

Products | PSTextMerge

PSTextMerge Examples

Several sets of sample files are included with the PSTextMerge distribution, in the sub-folder named "examples". Following are explanations of the features demonstrated in each example, along with links to the resulting HTML that will be created, where applicable. Looking at such examples is often the best way to learn how to use the program. You can start with any of these files and modify them to suit your purposes. You should be able to run PSTextMerge yourself and use the accompanying scripts to re-generate the output.

When you look at the following examples, they will be opened in a separate window. Close the window, rather than clicking on the back button, when you are done looking at the output.

Example 1 — Creating a Simple HTML Table from Tab-Delimited Data

In this example, we create a simple HTML file from the input data. This example uses the following files.

  • changes.txt — This is the input tab-delimited file, containing information about changes to PSTextMerge.
  • example1.tcz — This is the script file. It will open the data file, sort the data, identify the template file to use, and then generate the template output.
  • example1_template.html — This is the template file, containing the desired HTML and PSTextMerge commands.
  • example1.html — This is the resulting HTML file generated by PSTextMerge.

Example 2 — Creating Nested Lists from Tab-Delimited Data

In this example, we use the group commands to look for control breaks (changes in sequence fields), and then generate multiple, indented lists when we find them. This example uses the following files.

  • bookmarks.txt — This is the input tab-delimited file, containing information about some Web sites.
  • example2.tcz — This is the script file. It will open the data file, sort the data, identify the template file to use, and then generate the template output.
  • example2_template.html — This is the template file, containing the desired HTML and PSTextMerge commands.
  • example2.html — This is the resulting HTML file generated by PSTextMerge.

Example 3 — Creating Multiple Pages from Tab-Delimited Data

This is similar to example 2, but we now create an index page listing all of the top-level bookmark categories, and then separate, hyperlinked pages for the bookmarks within each category. The technique illustrated is to use a variable within the output command, and put the output command after the nextrec command, rather than at the top of the template file.

  • bookmarks.txt — This is the input tab-delimited file, containing information about some Web sites.
  • example3.tcz — This is the script file. It will open the data file, sort the data, identify the template files to use, and then generate the template output. Note that even though we use two different template files in this example, one script file can be used to generate output from both of them.
  • example3_index_template.html — This is the template file for the single index page, containing the desired HTML and PSTextMerge commands.
  • example3_page_template.html — This is the template file for each top-level category.
  • example3.html — This is the resulting HTML index file generated by PSTextMerge, with links to the individual data pages.
  • example3_pages — This is a folder containing individual, generated pages for each top-level category. Note that this folder must exist before running this program — PSTextMerge will not create an output folder.

Example 3a — Creating Multiple Pages from Tab-Delimited Data, with Frames

This is similar to example 3, but the index page and current category page are made visible within HTML frames, so that the index page is always visible on the left.

  • bookmarks.txt — This is the input tab-delimited file, containing information about some Web sites.
  • example3a.tcz — This is the script file. It will open the data file, sort the data, identify the template files to use, and then generate the template output. Note that this example generates the same category files within "example3_pages" as example 3.
  • example3a_index_template.html — This is the template file for the single index page, which will appear in the leftmost frame.
  • example3a_index.html — This is the generated index page, which will appear in the leftmost frame.
  • example3_page_template.html — This is the template file for each top-level category.
  • example3a.html — This is the top page defining all the frames. It is not created by PSTextMerge.
  • example3a_head.html — This is a heading that will permanently sit in the topmost frame. It is not created by PSTextMerge.
  • example3a_start.html — This is the starting page that will fill the rightmost frame, before the user selects a desired category. It is not created by PSTextMerge.
  • example3_pages — This is a folder containing individual, generated pages for each top-level category. Note that this folder must exist before running this program — PSTextMerge will not create an output folder.

Example 4 — Creating a Simple HTML Table from File Directory Data

In this example, we create a simple HTML file from the "examples" file directory. This example uses the following files.

  • examples — This is the file directory whose data provides the input.
  • example4.tcz — This is the script file. It will open the directory, identify the template file to use, and then generate the template output.
  • example4_template.html — This is the template file, containing the desired HTML and PSTextMerge commands.
  • example4.html — This is the resulting HTML file generated by PSTextMerge.

Example 5 — Creating a Simple HTML Table from a Bookmarks HTML File

In this example, we read an HTML file containing bookmarks and generate it back into a different format.

  • example2.html — This is the input HTML file, with nested lists organizing the bookmarks by category.
  • example5.tcz — This is the script file. It will open the input file, sort the data by categories, identify the template file to use, and then generate the template output.
  • example5_template.html — This is the template file, containing the desired HTML and PSTextMerge commands.
  • example5.html — This is the resulting HTML file generated by PSTextMerge.

Example 6 — Generating Templates from Meta-Templates

In this example, we use PSTextMerge to generate templates for us, by using a data dictionary and meta-templates. This is a multi-step process. First, we start with one or more "meta" templates: templates for creating templates. Next, we open our intended data source as input, then write it out as output, requesting that a data dictionary be saved. Next we open the data dictionary as an input file. Since each row of the data dictionary describes one column in our data source, we can use NEXTREC and LOOP commands to iterate through the dictionary, so that all the fields will appear in our template. Finally, we use the generated templates and the original data source to create HTML files as our final output. You can use this technique to generate your own templates by either modifying the provide meta-templates, or using them as is with your data source, and modifying the output templates.

  • changes.txt — This is the input tab-delimited file, containing information about changes to PSTextMerge.
  • example6.tcz — This is the input script file. It will run through the process described above.
  • example6.txt. — This is the output text file. It is not used itself, but is created in order to create the next file, a data dictionary.
  • example6.dic. — This is a data dictionary file. See Section 6.1.2 for a complete description of the data dictionary format. Basically, this is itself a tab-delimited file, but with the field names and attributes listed as rows within the file.
  • example6_index_meta_template.html — This is a template for creating an index template. The index page will contain a link to each of the resulting pages.
  • example6_page_meta_template.html — This is a template for creating a page template. One page will be created for each row in the original data file.
  • example6_index_template.html — This template is generated automatically.
  • example6_page_template.html — This template is generated automatically.
  • example6_index.html — This is the final index page.
  • example6pnn.html (where "nn" is a change number) — These are the resulting detail pages.

Example 7 — Merging Two Files and Combining Duplicate Records

In this example, we merge two files containing name and contact information and then combine records where two exist for the same person.

  • example7.tcz — This is the script file. It will open the first data file, merge the second data file with the first, sort the data by last name and first name, combine duplicate records, and then save the results as a new text file.
  • example7a.txt — This is the first input tab-delimited file, containing last name, first name and e-mail address for three fictitious people.
  • example7b.txt — This is the second input tab-delimited file, containing last name, first name and telephone numbers for three fictitious people.
  • example7c.txt — This is the output tab-delimited file, containing last name, first name, e-mail address and telephone number for the four people identified in the two input files.

Example 8 — Extracting Tabular Data From an HTML Table

In this example, we read an HTML table and extract the data from it, saving it as a tab-delimited text file.

  • example8.tcz — This is the script file. It will open the HTML file and then save the resulting text file.
  • example1.html — This is the HTML file from example 1, containing a change history table. It will be used as input here.
  • example8.txt — This is the output file containing the extracted data from the HTML input.

Example 9 — Merging an HTML Table with a File Directory

In this example, we read an HTML table and extract the data from it, merge the data with a multi-level file directory listing, then output an updated version of the HTML table that was used as input.

  • example9.tcz — This is the script file. It will open the HTML file, merge the file directory information, filter and sort the data, then use a template to re-create the HTML table.
  • example9.html — This is the HTML file that is used as both input and output. Each time that the script is run, the file directory information (file sizes, last modified date and time, etc.) will be updated in the table. Other information, such as file description, will be preserved.
  • example9_template.html — This is the template used to re-generate the HTML file.
  • example9_folder — This is the folder whose directory and sub-directory information will be read.

 

Home | Downloads | Donations | Store | Support | Products

Copyright © 1999-2008 Herb Bowie • All rights reserved • E-mail:

http://www.powersurgepub.com/ | examples.html | Revised: 6/15/08

Google
WWW PowerSurgePub.com