See also: BagMapStackQueue

OVERVIEW

Replaces tokens in a template file. The concept is that it allows you to perform context sensitive text replacements without regard to surrounding text. This program is best suited for use when you wish to perform contextual search and replace. With the provied templates you can generate typed collections of unique or mapped values, stacks, or queues for most any data type by creating a .param file with appropriate values. The use of .param files allows you review and tweak the values used as well make copies to use as a starting point for a new typed collection. The template can use any extension but using .bas, .inc, or .bi will allow you to get syntax highlighting from the PB/IDE.

I generally prefer using typed operations to untyped operations so this framework provides a minimal templating engine to facilitate that.

While you can create collections of classes it should be noted that minimal classes take around 150 bytes of memory per instance. As a result at most you can have a class collection of around 13 million objects.

  • doall.cmd - Generate all the example .inc files in the test subdirectory.
  • clean.cmd - Remove generated .inc files and any .exe files from the test subdirectory.
  • test\buildall.cmd - After generating .inc files, you can use it to build all the test programs. It's set to compile with PBCC using a default install. Be sure to edit the file to update if you installed elsewhere or used PBWin 10.

pbReplace operates by processing a parameter file. The parameter file must conform to the following format:

:input=filename
:output=filename
.TOKEN
value
:end

:input defines what template input file to read and replace tokens from.

:output defines what file with the replaced tokens will be written.

.TOKEN defines a token that will be replaced from the input stream.value is the value for token. The value may span multiple lines but the last line has the Cr/Lf removed. If you want a trailing Cr/Lf be sure to leave a blank line

:end indicates there are no more tokens or files, anything after this is treated as a comment.

In the template file tokens take the form of {TOKEN}. That is in the parameter file .TOKEN has the period removed and curly braces added around it. i.e. .TOKEN searches for {TOKEN}.

You can provide many parameter files for each template file. This facilitates creating many collections from a single template.