PbSlice2 Core Functions

PbSlice is a project for manipulating PowerBASIC source code.  This project includes the core source code and test routines for the PbSlice API.  The API is provided as a series of Subs and Functions that can either be included directly in your project or via a DLL.  These routines were separated to facilitate use in multiple projects.  Currently there are no dependencies on external include files.  This was done to make it easier for projects using differing include files that do not wish to use the DLL.

The project currently provides some capabilities in project-management, editing, refactoring, and code-generation categories.  These will be enhanced over time.

It is the intent of this project to enhance my ability to manipulate source code and automate time consuming repetitive tasks.  It is released as Public Domain in the hopes that others may also find a use for it or even possibly contribute enhancements to it.

Using PbSlice200.dll

The PbSlice200DLL.inc provides declarations for use of PbSlice200.dll.

  1. Place PbSlice200.dll in your project directory or a search path.
  2. Add the following line to your project: #include "PbSlice200.inc"
  3. Place PbSlice200.inc in your project directory or one of the compiler include directories for compiling: Window | Options | Compiler | Include in the PbWin/PbCC IDE.

Using PbSlice Source Code

If you want to include the source directly in your project:

  1. Either:
    1. Place the PbSlice source code in your project.
    2. Set a compiler include path to c:\Prj\Pb\PbSlice2\src, or the directory you placed the PbSlice source code In the PbWin/PbCC IDE use the following menu options: Windows | Options | Compiler | Include.
  2. Ensure src\PbSlice.inc has the path you placed the source in.  Replace ALL c:\Prj\Pb\PbSlice2\Src with the directory you're copy of the source is.

You can look at pbsFix.bas and pbsTest.bas in the test directory for examplesof using the source directly.

Terms

Activate
Make a file or snippet the target of future api operations.
Alias
The name specified in the Alias clause for a Sub, Function, Method or Property.
Base path
The directory the original Project file was loaded from.
BBCode
Formatting codes used by the PowerBASIC forums.
Builtin
A PowerBASIC pre-defined symbol See Keyword.
Continuation
Short for a line continuation i.e. _
Definition
The source code for a declaration May be a single line, such as for variables, or multiple lines, such as for a Sub.
Declaration
The name and location of an asmdata, class, constant, enum, fastproc, field, function, interface, label, macro, method, property, reference, sub, type, union, or variable were defined.
External
A file that is not in the Project directory or one of it's sub-directories.
File
A single file in a project collection.
Keyword
A language element as pre-defined by PowerBASIC Does not include operators.
Load
Load source file from disk into memory.
PbSlice core
The API routines that allow manipulation of source code.
Project
The collection of files that would be compiled by loading one file.
Save
Write memory source file to disk.
Signature
The line containing a declaration.
Snippet
A set of unrelated source codes May be related to files or not.
Token
A single word as defined by the PowerBASIC language. i.e. +, For
Whitespace
A space (Ascii 32) or tab (Ascii 9) characters.

API Notes

Files and snippets are designed to be activated.  Subsequent calls to the API use the last activated file or snippet.  You can use either Activate or New routines.

To use any declaration routines you must first perform a scan.  Many routines will alter the number or lines or locations of declarations.  Whenever one of these routines is used, you must rescan before using another declaration routine.

Adding a file to a project is temporary.  To permanently add a file to a project you should add a #Include to the source code.  Then future Loads or Reloads will include the file.