General

So you want to create a template for PCProfiler, eh? Well, it's not so hard. Hontest! First though, let's examine how the PCProfiler program uses these templates, and exactly what a template is.

How PCProfiler handles templates.

Find your PCProfiler directory (where the PCProfiler.exe file is), and navigate to the \Templates subdirectory. What do you see? A collection of *.pcpt files, which are PCProfiler Template files. You'll also see a collection of subdirectories, with names identical to some of the *.pcpt files. When PCProfiler fires up, it scans the \Templates directory for all *.pcpt files, and records their names which are used as the template name. So, the file "3ED&D General Extended.pcpt" becomes the "3ED&D General Extended" template. Each subdirectory contains files that the respective template depends on. Look in the "\Templates\3ED&D General Extended" subdirectory, and you'll see a collection of javascript files, cascading style sheet files, some helper html files, and a few images that the template uses. Each template stores its files in a directory bearing its own name to avoid overwritting data files from other templates. So, that's how templates are handled, but...

What exactly is a template?

Open your favorite text editor, and drop in a *.pcpt file. Kinda looks alot like HTML, no? That's because it is. A PCProfiler template is simply an html document. What does this mean? Simple: (almost) anything you can normally do with HTML can be done on a PCProfiler template. That pretty much means you can make your template look any way you want, only your ability to generate HTML code will limit what your PCProfiler template will look like. How's that for flexibility?

Take it a step further though. PCProfiler does more than just use HTML as a language to render templates, the program is actually based off Microsoft Internet Explorer technology. Need to get fancy with your template? How about specific style definitions with CSS, or event handling through scripting. Ever use JavaScript in a webpage? You can use it in PCProfiler. But don't stop there, since we're working with an Explorer based technology, any of the Microsoft extentions to the HTML DOM, as well as other scripting languages like VBScript can be used too. With some solid HTML and scripting code, you can do alot with a PCProfiler template.

So, how is the data handled?

Great! So far, you have a vague idea of how templates work in PCProfiler, what a template is, and if you have alot of web-design experience, you may already have a good idea of how to go about making a template. But how is the data handled? How does PCProfiler extract data from the modified template, and save it to disk as a *.pcp file? The answer lies in certain target HTML elements.

An HTML form is the basic unit of data entry on the web. Any time you fill out information when registering for a community forum, or enter your shipping information for an online purchase, you're dealing with a form element. A form can contain a small selection of elements which act as editable controls on an internet page. Things like text boxes, buttons, checkboxes, etc.

When you save a document in PCProfiler, the engine searches the entire document for specific target elements, records the value that you've entered, and saves it to disk. Similarly, when you open an existing character, PCProfiler first renders the base (empty) template that your character is drawn to, then the program fills in all the values that you had when you last saved your document.

The data that PCProfiler keeps is completely independent of the template that your data is drawn to. This may seem to be a mundane fact, but it is actually very important, and a very powerful feature that template designers can take advantage of. More on that later.

So, what are these target elements that PCProfiler scans for data?

<INPUT type=text>      (Stores the value property)
<INPUT type=checkbox>  (Stores the checked property)
<INPUT type=hidden>    (Stores the value property)
<TEXTAREA></TEXTAREA>  (Stores the value property)
Collectively, all data in a PCProfiler document is presented in these elements. When PCProfiler saves a document, it scans for each of the above elements. It then records the name/id of the element, and the corresponding data property (either the value or checked property). When the document is re-opened, the blank template is first drawn, and then each element's data is filled in if its name or id matches any of the data in the *.pcp file. No data about the template (other than the name of the currently used template) is kept at all.

Do you see how you can design a template to be compatible with existing ones? Let's say you want to make your own 3ED&D character sheet. If you try using inputs (type=text) by the name of Race, Class, Level in your template, you'll notice something cool. Open an existing character sheet drawn on the 3ED&D General Extended template, then switch to your new template. What happens? The Race, Class, and Level information on your new sheet is already filled out! Why? Because the 3ED&D General Extended template already has elements by the name of Race, Class, and Level. The data for the document is independent of the template. When you switched to the new template, PCProfiler found elements whose names matched existing data, so their values were filled in. This means, you can switch to different templates, and your data will be persistent. All that will change is how everything looks!

This also means that you can have completely different templates with seperate data. That's the case when comparing the 3ED&D General Extended template to the 3ED&D Spell Sheet. No data is shared betwen the two templates. Each has unique names for all of its elements. Whenever you switch to the other template, that template's data is drawn. The data from the other template still exists, but its not shown. So, all your data is there, you just choose which parts of it you want to see by choosing which template to draw over.