File Templates

A file template is the framework for a new file, which you can load into the IDE with the "New File As…" option.  While a template can contain anything you like, it is typically used to automate the basic boilerplate needed for a new document.  For example, the "Generic PB program" template creates a new file with the following information already filled out:

#COMPILE EXE

#DIM ALL

 

FUNCTION PBMAIN () AS LONG

 

   

 

END FUNCTION

What’s more, the caret is conveniently placed in the middle of the FUNCTION block for you, letting you get right to programming!

You can readily build templates of your own, or modify the ones that come with the IDE.  A template is simply a text file created according to a few simple rules.  Let’s look at the default template (you can load it into the IDE, NotePad, or any other text editor).  PowerBASIC templates use ".PBTPL" for their file extension.  The default template is "Default.pbtpl", then.  You can find it in the Bin subdirectory for your compiler ("C:\PBCC\Bin", by default).

The first line starts out with a number:

1

This is the template version number, 1 (one).  There may be other options in the future, but the number must always be 1, for now.

The second line contains the file extension to apply to files that are created with this template:

.bas

The third line gives the name of the template, which will be used in the "New File As…" menu:

Generic PB program

The following lines give the text to be filled into the file created by the template.  There is one special character, the "|" vertical bar or pipe symbol.  This indicates where the caret should be placed after the text is filled in.

#COMPILE EXE

#DIM ALL

 

FUNCTION PBMAIN () AS LONG

 

    |

 

END FUNCTION

That’s all there is to it!

After creating a new template, save the .PBTPL file in the Bin subdirectory for your compiler.  The default location for this is, typically, "C:\PBCC\Bin\".  Now, the next time you start the PowerBASIC IDE, your custom template will be available on the "New File As…" menu.

 

See Also

The Integrated Development Environment