Home GBIC >> Freeware >> gbSnippets >> Online Help

gbSnippets - Online Help

This page provides the latest online Help information for gbSnippets, a freeware source code librarian for PowerBASIC programmers.

For easier browsing, I've put the entire Help content into this single page. That makes for a long page, but I find that it supports searching and browsing more conveniently than moving between multiple web pages.

Overview of Features

gbSnippets allows a user to store text data (called snippets), using a familiar tree structure to organize and display the snippets. Snippet titles are displayed in the Tree, with snippet details displayed/edited in a source code (text) editor.

A listing of snippet titles can also be displayed underneath the Tree. While normally used to list snippet titles which match a search term, the display may also contain a list of bookmarked snippets or a list of snippets the user manually places in the list for convenience.

Two search types are supported - a Tree search and a Node search. The Tree search present a list of all snippets containing a search term, whereas the Node search highlights text in the text editor which matches a search term. The Tree search supports the use of boolean AND and OR terms. The Node search supports replacement of the search term.

A Tree search is performed by entering a search term in the dropdown combobox directly above the Tree. Navigation buttons, found next to the combobox where the Tree search term was entered, are used to walk through the list of matching snippets.

A Node search is initiated by entering F3 or pressing the node search toolbar button. Both pop up a Find & Replace dialog.

gbSnippets provides menus, a toolbar and context menus to control the display of information. These are discussed in detail further down this Help page.

An unique feature of gbSnippets is that the top line of a snippet is used as the snippet title that is displayed in the Tree. Editing the snippet in the text editor will also modify the title displayed in the Tree. You can also edit the snippet title directly in the Tree. gbSnippets will synchronize your snippet title inputs!

Snippets are stored in text files, called libraries, with the extension "gbs". gbSnippets opens only one snippet library at a time, and one library is always open. By default, gbSnippets opens the file used in the last session. If the file does not exist, a default file will be created and displayed.

gbSnippets ships with several snippet libraries, kept in a subfolder called "snippets". As a means of quickly finding snippet libraries, the down arrow next to the Open toolbar button displays a list of the libraries found in that folder. Library files may be kept anywhere, but are easier to access if kept in the "snippets" subfolder.

The text editor allows you to click on Internet URL addresses to open your default browser at that address. You may also enter and click on links to other snippets within the library. The details for entering internal links are discussed below.

Bookmarking is supported. One or more snippets may be bookmarked, a list of bookmarks displayed, and bookmarked snippets cycled through for viewing/editing. In addition to bookmarks, one node may be designated as the "home" node, which can be conveniently selected and accessed from the toolbar.

Finally, this version of gbSnippets uses the Scintilla edit control (the RichEdit control is no longer used as the text editor). In addition to providing smoother, more stable editing, Scintilla has made it easier to add several new features, including line numbers, Intellisense-like capabilities (Call Tips and AutoCompletion), code folding, greenbar effect, indentation guidelines, and more. Display of syntax highlighting on large snippets is also noticeably faster.

Installation

gbSnippets is distributed as a single file, "gbsnippets.zip". Simply place the file in a folder of your choice and unzip the file. The contents will be extracted into a subfolder called "gbnsippets_s", which will contain the gbSnippets files and any required subfolders.

If you want a shortcut to gbSnippets on your desktop, simply right-mouse click on the gbSnippets EXE file and use the Send To > Desktop options to create the shortcut.

gbSnippets does not use the Windows registry. To remove gbSnippets from your system, simply delete the folder in which it resides. If you've modified any of the snippet libraries, don't forget to move/save those.

Running a Snippet

A snippet can consist of any text information the user wishes to place in it. However, to designate a portion of the code as a compilable example, a line must be entered exactly as follows:

    'Compilable Example:

All code following that line is considered to be a compilable code example, which gbSnippets can open in the PowerBASIC IDE (PBEdit.exe) or compile and run by using the PowerBASIC compiler (PBWin.exe).

The "Open Snippet in IDE" toolbar button (or Ctrl-E) is used to load the compilable code example from a snippet into the PowerBASIC IDE. It does so by saving the compilable example from the snippet into a file called "gbsnippets_temp.bas", and then opening that file in the PowerBASIC IDE.

Once the PowerBASIC IDE is visible, and contains the compilable source code, pressing Ctrl-E will execute and run the code. So pressing Ctrl-E twice will load and execute the compilable example portion of a snippet.

The "Compile and Execute" toolbar button is used to compile and execute the compilable code example from a snippet without first being entered into the PowerBASIC IDE.

Normally, a BAS is compiled to an EXE of the same name - i.e., test.bas is compiled to test.exe. But if the following statement is used, the compiler will generate an EXE with the given name.

    #Compile EXE  "test.exe" 
    
The EXE name in the #Compile statement can contain a full path.

To open a snippet in the PowerBASIC IDE, gbSnippets first saves the compilable example from the snippet in a temporary file named "gbsnippets_temp.bas", found in the temp_projects subfolder. That file is used to send the code to the PowerBASIC IDE or compiler. Unless specified otherwise, by using the #Compile statement, the PowerBASIC compiler places the resulting EXE in the same folder as the temporary file.

The gbsnippets_temp.bas and gbsnippets_temp.exe files are overwritten each time a new compile and execute task is performed.

Online Update

The gbSnippets EXE file can be updated online by selecting the Help > Online Update menu option. This will compare the local gbSnippets version number with the one available at the gbSnippets server. If a new version is available, the use must approve the update.

This feature covers only the gbSnippets executable file, gbSnippets_s.exe. None of the other files in the gbSnippets distribution are included in the update in order to avoid overwriting an update to those files which may have been made by the user.

A section is provided at the bottom of this Help file, giving a list and links to the support file updates that are available from the gbSnippets server.

Menus

Like most Windows programs, gbSnippets provides a wide selection of menu options. Here's a summary listing of the menus and submenus available from the menu bar. Individual menus are discussed further down this page.

File
New
Open
Save
Save As ...
-----
Print Node
Export Node
-----
Exit
Actions
Display Tree Summary
Display Snippet Summary
Display ASCII Table
-----
Capture Dialog
-----
Select Compiler
Select Includes Folder
Display Compiler/Include Path
-----
Create Library From Folder
Create Library From Folder (w/Redirection)
-----
PBCodec
Options
Confirm Delete
On Top
Layout
    File Name in Caption
    AutoShow Search Results
Tree Search
    Include Parent Title
    Case Sensitive
    Search While Typing
Startup/Exit
    Load Last File on Startup
    Save Tree Position on Exit
    AutoSave Changes on Exit
Export
    Open HTML on Export
    Use gbs# on Export
    Convert TABs to Spaces
Editor
Select Keyword Color
Select Comment Color
Select String Color
-----
Line Numbers
GreenBar
Active URLs
Syntax Highlighting
Brace Highlighting
Indentation Guides
Call Tips
AutoCompletion
AutoIndent
Code Folding
-----
As Typed
Lower Case
Upper Case
Help
Email Author
Daily Message
-----
Online Update
Online Help
-----
About

Here is additional information on each of the menu items.

File Menu
gbSnippets files are text files which use a "gbs" extensions. By default, gbSnippets is set to open the powerbasic.gbs library, which contains over 750 PowerBASIC source code snippets.

gbSnippets ships with several snippet libraries, kept in a subfolder called "snippets". As a means of quickly finding snippet libraries, the down arrow next to the Open toolbar button displays a list of the libraries found in that folder. Library files may be kept anywhere, but are easier to access if kept in the "snippets" subfolder.

The File menu provide the following options for managing snippet library files.

    New Creates a new file named "gbsnippets.gbs" and places it in the "snippets" folder. If that filename exists, a different filename is used (typically, "gbsnippets001.gbs").
    Open Opens an "Open File" dialog asking the user to select an existing *.gbs library file to open. If the current file has unsaved changes, the user is prompted (optional setting) to save the changes before the dialog is opened. The selected file to open is added to the file MRU (most recent used) list.
    Save Saves all changes, using the current filename. The user is not prompted to confirm.
    Save As Opens a "Save As" dialog, prompting the user to select a new filename and location to save the current data. If the current file has been changed, the changes are included in the new file. The current file is not changed.
    Print Node The content of the currently selected node is printed. A Printer dialog is opened to allow the user to select a printer. If the node is a parent node, its children are printed.
    Export Node The content of the currently selected node can be exported to HTML format. Each snippet gets its own file and all export files are placed in a subfolder called "HTML". Any pre-existing files contained in the folder are deleted when an export is done. If the node is a parent node, its children are exported and an index page is also created with links to the children pages.
    Exit Closes gbSnippets, optionally prompting user to save any changes before exiting.

Actions Menu
As a convenience to the programmer, these menu options display Tree/Snippet summaries, an ASCII table or capture an image of the gbSnippets main window. The menu also provides features related to code compilation, source code import, and access to external tools which can analyze the content of snippets.

    Display Tree Summary Displays a popup dialog with parent/child counts plus a summary of the largest snippets in the Tree.
    Display Snippet Summary Displays a popup dialog with character, line and size information about the current snippet.
    Display ASCII Table Displays a popup dialog with character ASCII values.
    Dialog Capture Captures an image of the gbSnippets main window (dialog) and places it on the clipboard.
    Select Compiler Displays a popup dialog for selecting the compiler. A default of c:\pbwin90\bin\pwbwin.exe is used.
    Select Include Path Displays a popup dialog for selecting the path to include files. A default of c:\pwwin90\winapi is used.
    Display Compiler/Include Path Displays a message box that lists the current compiler and include paths.
    Create Library From Folder Creates a library file from all *.bas files beneath a specified folder.
    Create Library From Folder (w/Redirection) Creates a library file from all *.bas files beneath a specified folder, but also modifies #Include, #Resource, and other file names to point to the file at its location in the specified folder.
    PBCodec Saves the current snippet to a temporary file and opens that file in PBCodec (the updated version released by Nathan Maddox).

Options Menu
These menu options allow a user to toggle an option On/Off.

    Confirm Delete Requires the user to confirm deletion of Tree nodes. It does not apply to deleting text within the text editor.
    On Top Places gbSnippets at the top of the z-order for all open applications.
Aside from the Confirm Delete and On Top menu items, the other options are separated into four categories - Layout, Tree Search, Startup/Exit and Export.

    Layout
      File Name in Caption
      Places the name of the currently opened file to the gbSnippets caption.
      AutoShow Search Results
      Automatically displays the Search Results listbox when Enter is pressed in the search combobox or when the "Tree Search" button is pressed. This happens only if matching snippets are found.
    Tree Search
      Include Parent Title
      Includes the immediate parent title, but not 2nd level or higher parent titles, in a Tree search.
      Case Sensitive
      Makes all Tree searches case sensitive. The default is case-insensitive searches.
      Search While Typing
      Executes a Tree search for each character entered into the Tree search combobox. Focus stays with the combobox. This is especially useful in minimizing the number of keystrokes a user must enter to get the matching snippets.
    Startup/Exit
      Load Last File on Startup
      On startup, opens the last file that was opened in gbSnippets.
      Save Tree Position On Exit
      When exiting, the position of the currently selected node is saved. When gbSnippets is restarted, it attempts to open in the same position. This is meaningful when the option to reload the last opened file is set. But even if that option is not set, the saved Tree position is still used.
      AutoSave Changes on Exit
      Automatically saves changes when exiting, without any confirmation by the user.
    Export
      Open HTML on Export
      Automatically opens an exported HTML file. However, if a node + its children are exported, gbSnippets created an index.htm file with links to all of the exported snippets. In that case, the index.htm file is automatically opened.
      Use gbs# On Export
      When exporting snippets to HTML, the file names can be sequentially numbered or can include the gbs# (that is found within the snippet) in the filename.
      Convert TABs to Spaces
      HTML does not support TABs, so this option allows TAB characters to be replaced with a series of spaces - placing text in the HTML files at approximately the same location as the tabstops in the snippet.

Editor Menu
Aside from the Confirm Delete and On Top menu items, the other options are affect display colors, lexer options, and text case.

    Keywords
    Selects the color to use in syntax highlighting of PowerBASIC keywords.
    Comments
    Selects the color to use in syntax highlighting of PowerBASIC comments.
    Strings
    Selects the color to use in syntax highlighting of PowerBASIC strings.
     
    Line Numbers
    Displays line numbers in a margin to the left of the text editor.
    Greenbar Effect
    Alternately sets background of every 3 lines in the text editor.
    Active URLs
    Activates URLs found within the snippet, allowing the user to click on the URL to open it in the default browser.
    Highlighting
    Applies syntax highlighting to the content of the text editor content.
    Indentation Guides
    Displays vertical lines which correspond to the columns where indentation is set.
    Call Tips
    When the user types in a PowerBASIC function, a call tip is displayed which gives the proper syntax for that function.
    AutoCompletion
    When the user types in a PowerBASIC keyword that is part of a predefined multi-keyword string, a listbox is displayed which gives the allowed PowerBASIC keywords which can be used to complete the string.
    Code Folding
    Folds all procedures within the Compilable Example.
     
    As Typed
    Displays all text as typed by the user.
    Upper
    Displays all PowerBASIC keywords in upper case. Note that this does not permanently change the content of the snippet, only the way in which it is displayed. The case as typed in by the user is maintained.
    Lower
    Displays all PowerBASIC keywords in lower case. Note that this does not permanently change the content of the snippet, only the way in which it is displayed. The case as typed in by the user is maintained.

Help Menu
Keeping in touch with the author, finding online help, and updating to the latest copy of gbSnippets are supported within the Help menu.

    Email Author Opens the user's default email client addressed to the author of gbSnippets (that would be me, Gary Beene).
    Daily Message Perhaps not daily, but a regular short message from the author with tips or news about gbSnippets.
    Online Help Opens the user's default browser to the gbSnippets online Help page.
    Online Update Checks online to see if a new version is available and with user approval updates gbSnippets with the latest version.

    Note: Only the gbSnippets executable can be updated this way - no other files are affected.

    About Opens an About dialog, with version information about gbSnippets and a link to the gbSnippets home page.

Toolbar

The toolbar provides quick access to some of the more often used features of gbSnippets.

Here's a description of the functions provided by the toolbar.

    New Create a new file and loads it into gbSnippets
    Open Displays the "Open File" dialog for selecting a gbSnippets library
    Save Saves all changes (uses current file name, no Save As dialog)
    Print Prints the content of the text editor to the default printer
    List Displays the Search Results (listview control)
    Collapse All Nodes Collapses all nodes in the Tree
    Expand All Nodes Expands all nodes in the Tree
    New Sibling Adds a node to the Tree (sibling to the selected node)
    New Child Adds a node to the Tree (child of the selected node)
    Delete Node Deletes selected node (if has children, confirmation required)
    Set Home Node Sets the current node as "home"
    Go To Home Node Selects the home node
    Undo Removes the latest change made in the text editor
    Redo Reverses the last Undo action.
    Fold Folds all procedures in the snippet's Compilable Example
    UnFold UnFolds all procedures in the snippet's Compilable Example
    Indent Indent the selected lines
    Outdent Un-indent (outdent) the selected lines
    Comment Comment the selected lines
    UnComment UnComment the selected lines
    Search Node Opens search dialog for the content of the text editor
    Open In IDE Opens snippet's Compilable Example (uses default BAS editor)
    Compile and Execute Compiles the snippet's Compilable Example and runs the resulting EXE

Context Menus

There are three context menus available - one for the Tree, one for the text editor, and one for the search results control. A description of each if given below.

    TreeSearch ResultsText Editor
 

Tree Context Menu
gbSnippets uses a cut/copy/paste method of handling nodes, available from the right context menu for the Tree.

    Node Cut
    Removes the node from the Tree and stores the information for optional pasting back into the Tree. This does NOT use the Windows clipboard.
    Node Copy
    Copies the node for optional pasting back into the Tree. This does NOT use the Windows clipboard.
    Node Paste as Child
    Pastes a cut/copied node into the Tree as a child of the currently selected node.
    Node Paste as Sibling
    Pastes a cut/copies node into the Tree as a sibling of the currently selected node.
    Set Bookmark
    Sets the bookmark property of the currently selected snippet. There is no visual indication of the bookmark property of a snippet. To see a list of all snippets whose bookmark properties are set, use the toolbar "Bookmark Search" button. The list will be displayed in the Search Result listbox.
    Clear Bookmark
    Clears the bookmark property of the currently selected snippet. There is no visual indication of the bookmark property of a snippet.
    Clear All Bookmarks
    Clears the bookmark property of all snippets in the Tree.
    Display Bookmarked Node List
    Lists all bookmarked snippets in the Search Result listbox. As with normal search results, selecting an item in the list will also selected the item in the Tree and display the full content of the snippet in the listbox.
    Sort Tree
    Sorts every node in the Tree. The sort is ascending.
    Sort Children
    Sorts the children of the currently selected node. It does not sort sub-nodes. The sort is ascending.
    Add to Search Results List
    Adds a node to the listbox. It's a way of creating a list of snippets on which to take action (such as copying to the clipboard).
    Edit Label
    Starts an in-place edit of the currently selected snippet. Remember that the title in the Tree and the first line of the full snippet content in the textbox are kept synchronized. Whatever is typed in the in-place Tree edit will replace the first line of content in the textbox, and vice versa.

Text Editor Context Menu
In general, the text editor context menus options are used to modify the content of the textbox. If a text selection has been made, the menu options work on the selected text or lines containing the selected text, depending on which is appropriate.

    Cut
    Removes the selected text and places a copy on the clipboard.
    Copy
    Copies the selected text to the clipboard. The original text is not affected.
    Paste
    Pastes the current contents of the clipboard into the textbox at the caret. If a selection has been made, pasting replaces the selected text.
    Delete
    Deletes the selected text. The deleted text is NOT placed on the clipboard.
    Select All
    Selects all text in the textbox.
    Copy All
    Copies all text in the textbox. The text is NOT selected. Any selection remains selected.
    Copy Current Line
    Copies the content of the current line (where the caret is located) to the clipboard. The line is NOT selected. Any selection remains selected.
    Left Justify
    Left justifies selected lines (removes all leading spaces).
    Format Code
    Indents selected lines based on hierarchical code content
    Add Selection to Procedure Library
    Asks the user for a title under which to list the selected text in the procedure library.
    Insert Procedure
    Displays list of code blocks found in the procedure library. Double-click on a procedure to insert it into the text editor at the cursor. The procedure library comes with a dozen or so entries that I find myself using in many snippets.

    The code blocks are found in the support_files\procedure_library.txt file. You can manually edit the file or simply delete it to erase all code blocks. If manually editing the file, be sure to look at the content to see how code blocks are formatted.

Search Results Context Menu
The list of matching snippets is particularly useful for browsing all matching snippets of a search. Clicking on a snippet in the list also selects the same snippet in the Tree, causing the entire snippet to be displayed in the textbox.

The list of matching snippets can be printed, or sent to the clipboard. Where snippets are primarily one-line snippets, this is especially useful.

    Remove From List
    Removes the selected snippet from the list. It does NOT remove it from the Tree. This is useful when you're walking through a list - removing each snippets as you view it, leaving behind only those snippets you've not yet seen or are interesting in looking at again.

    Clear List
    Completely clears the list. Keeping the list empty, when through with it, can be useful to visually indicate when a new list has been generated.

    Print List
    Prints the list - just the contents of the list (titles only), not the full content of each snippet in the list. This is especially useful for printing one-line snippets. It's also a great reason to place key information in the top line of the snippet, rather than several lines down.

    Copy List to Clipboard Copies the list to the clipboard - just the titles of the snippets in the list, not the full content of each snippet in the list.
    Copy Snippets to Clipboard Copies the content of each snippet listed in the listbox to the clipboard.

Searches

gbSnippets provides two separate methods of searching - a Tree Search and a Node Search.

Tree Search
A tree may be searched for snippets which match one or more search terms. To initiate a tree search, simply type in the search term in the combobox located just above the tree and press Enter. Matching snippets will be displayed in the search results listbox at the bottom of the page. The first matching snippet is selected in the tree.

When multiple matching snippets are found, navigation between the matching snippets can be done in two ways. Next to the combobox, where search terms are entered, are two buttons - magnifier icons, corresponding to moving up and down the list of matching snippets.

Alternately, clicking on a snippet in the listbox will jump to that specific snippet - highlighting it in the tree and displaying its content in the textbox.

Tree searches support Boolean (AND, OR) searches as well as exact string searches. Quotes are not used. These are all valid search terms:

  • cookies - searches for the string "cookies"
  • my cookies - searches for the exact string "my cookies"
  • milk and cookies - searches for snippets with both words
  • milk or cookies - searches for snippets with either word

As was discussed in the menu and toolbar discussions, there are several tree search options which control how a search will be made and how search results will be displayed. Those options are repeated here for convenience.

  • Show Search Results
    toggles display of the Search Results listbox (toolbar button)

  • AutoShow Search Results
    displays the Search Results listbox whenever a tree search is executed.

  • Case Sensitive Search
    toggles case-sensitivity in tree searches. This does not apply to a text editor search, where case-sensitivity can be independently set.

  • Include Parent Title in Search
    includes the title of the selected node in the search (only the immediate parent title is used - 2nd-level or higher parent titles are not included).

  • Search While Typing
    automatically executes a search whenever a key is entered in the combobox. Focus stays with the combobox. This is especially useful in minimizing the number of keystrokes a user must enter to get the matching snippets.

Finally, the last 10 search terms are placed in the combobox. Simply press the combobox down arrow to display the most recent searches and select an item to repeat the search. Each time a search is made, the search terms are added to the top of the dropdown list. Duplicate entries are ignored.

Node (Text Editor) Search
The content of a selected node can be searched for a specific text string by pressing F3 or by selecting the "Search Snippet" toolbar button.

Enter or press one of the search buttons to find and highlight matching text. The Enter key can also be repeatedly pressed to search forward through the node content.

A text editor search is limited to the content of the currently selected node. When the end of the node content is reached and no further matches are found, pressing the search buttons will result in a beep sound.

If a tree Search has been previously made, the text editor search dialog will open with the first word of the most recent tree Search.

A text editor search does not support Boolean (AND,OR) searches. The search can be made case-sensitive by selecting the checkbox on the text editor search dialog.

The text editor search dialog also allows replacement of the search term. Once a matching text string is found, and highlighted, pressing "Replace" or "Replace All" will replace the search string with the replacement string.

The "Next Match" and "Previous Match" buttons allow the user to move through the search results listing (not through the entire tree).

HTML Export

A snippet, or a parent node and it's children nodes, may be exported as HTML and will be placed in the subfolder "HTML". A file is created for each node, plus an index file with links for all nodes if a parent node was selected for export.

The Compilable Example content of the snippet is inserted into an HTML template. The template is located in the "support_files\gbsnippets_html.htm" file. This file may be edited freely by the user to create a customize template in which to place the exported snippet. See the content of the referenced file for information on how to create the template.

Before creating new HTML files, all files in the HTML folder are deleted.

Script Commands

gbSnippets has over 30 built-in functions which are considered low-priority capabilities - either not worthy of menu/toolbar space or simply functions which I've added for my own test purposes. These functions can be run by the user entering a special command into the Tree Search combobox. All script commands start with ".." followed by one or more keywords and/or arguments. Script commands do not initiate a tree search, even though they are typed into the combobox, where search commands are also entered.

These script commands take an action but do not generate a summary display. No snippets are modified.

  • ..x
  • - exit from gbSnippets
  • ..co
  • - clear Open MRU list
  • ..cs
  • - clear Search MRU list
  • ..cp
  • - toggles printing of message traffic in a console
  • ..cpx
  • - removes the console
  • ..split
  • - moves splitter bars to default positions

These script commands display a result within a popup messagebox, and the results are placed on the clipboard. No snippets are modified.

  • ..gbs
  • - displays gbs# summary
  • ..script
  • - list available script commands
  • ..tabc
  • - list snippets that have TAB characters
  • ..equates
  • - identify unused equates in current snippet
  • ..path
  • - displays compiler/include paths
  • ..db val
  • - convert decimal to binary (val = value to convert)
  • ..dh val
  • - convert decimal to hex (val = value to convert)
  • ..hd val
  • - convert hex to decimal (val = value to convert)

These script commands modify display options or other settings. No snippets are modified.

  • ..font
  • - set font
  • ..fontv
  • - lists current font information

These script commands generate a temporary file which is then displayed in Notepad.exe. No snippets are modified.

  • ..listall
  • - list all snippet titles

     

  • ..match sterm
  • - lines containing search term (this snippet, w/o line numbers)
  • ..matchl sterm
  • - lines containing search term (this snippet, w/line numbers)
  • ..matchall sterm
  • - lines containing search term (all snippets, w/o line numbers)
  • ..matchalll sterm
  • - lines containing search term (all snippets, w/line numbers)

     

  • ..tally
  • - # times pre-defined search terms are used in this snippet
  • ..tallyall
  • - # times pre-defined search terms are used in all snippets
  • ..tallylist
  • - opens pre-defined search term list (used by ..tally)

     

  • ..words
  • - get list of words in snippet
  • ..wordsx
  • - get list of unique words in snippet

     

  • ..ptt
  • - lists snippet titles (parent+children)

These script commands modify the content of the selection within a snippet. Use with care!

  • ..trim
  • - trims trailing spaces from selected lines
  • ..sorta
  • - sorts selected lines (ascending)
  • ..sortd
  • - sorts selected lines descending
  • ..lower
  • - converts selected text to lower case
  • ..upper
  • - converts selected text to upper case
  • ..tab2
  • - convert tabs to spaces in selected text

Create Library From Folder

gbSnippets now has the ability to create a library from all of the *.bas files found within a folder and its subfolders. The process involves copying the content of the *.bas files into a gbSnippets library file. No changes are made to the original files.

Use the Actions > Create Libary From Folder option to select the folder from which all *.bas files will be used to create a new gbSnippets library. Once a folder is selected, a library file name (without the *.gbs) is entered, at which point the library will be created from the *.bas files in the selected folder and its subfolders.

If the entered filename already exists, the user will be prompted for permission to overwrite the file.

This feature has the immediate benefit of allowing users to combine all of the PowerBASIC samples into a library, which can then be searched for sample code of interest.

Redirection
Many user applications or PowerBASIC Sample programs require external files (from #Include, #Resource, or other lines of PowerBASIC code) to be able to compile or execute correctly. In support of this, gbSnippets can optionally read file names within the *.bas source code file and replace those file names in the library with the absolute file path - pointing to the original file. This is called redirection and is a completely optional feature.

Redirection is important because when gbSnippets executes a snippet, it places a temporary source code file (gbsnippets_temp.bas) into the "temp_projects" subfolder. Redirection allows the temporary file to compile by correctly pointing to the needed external files.

Redirection has no effect on files which are not found within the same folder as the *.bas file. For example, "win32api.inc" will not be redirected because it is not found within the folder with the *.bas file that calls it. The include file can be found during compilation because it is located in the includes path that is specified by the user.

The redirection feature does not recognize some forms of file name specification that are used in PowerBASIC code, such as these:

   Exe.Path$ + "myfile.dat"
   Build$("c:\" + "myfile.dat")

In such cases, the redirection (replacement of a file name with the full path) may result in an inaccurate full path and must be corrected manually. In the case of the PowerBASIC Sample source code files, I found only 1 of the 83 files required the manual correction.

Go To Line

Using the key combination Ctrl-G will open a dialog in which a line number may be entered. The cursor will be moved to that line in the editor, and the editor will scroll as needed to ensure that the line is visible.

Unlimited Undo/Redo

The text editor now supports undo/redo actions, limited only by the amount of memory available on your PC. Undo/redo actions are taken by pressing the appropriate toolbar button. If an action is not available, the toolbar button will be grayed out.

Line Numbers

The text editor now supports the display of line numbers, contained in a left margin that is separate from the text.

Greenbar Effect

In the early days of computing, source code was printed on wide paper whose lines were alternately given white and green background colors. The alternating background colors made it easier for the eye to track across lines of code.

The greenbar display provides a similar effect by alternating (every 3 lines) between white and gray line backgrounds.

Active Links

gbSnippets supports hypertext links. Just as in a browser, the links are highlighted and underlined, needing only to be clicked to open the link location. Simply type in an HTTP address and click on the link to open the URL in your default browser. An

    http://www.garybeene.com

Hypertext links can point to Internet URL addresses, or they may point to another snippet within the current library. To link to another snippet, using the following link format, where the numeric part of the address refers to the gbs# of the target snippet.

    http://gbl_00015

Each of the snippets in the PowerBASIC source code library has been assigned a unique number such as "gbs_00001". This is referred to as a gbs#, and consists of a 5-digit numeric section. The gbs# of a snippet is normally placed at the bottom of the snippet as a comment, like this:

    'gbs_00015

Syntax Highlighting

Colors are used to distinguish keywords, strings, and comments from the rest of the snippet content. gbSnippets allows the user to select their own colors.

The list of PowerBASIC keywords is kept in the file keywords.txt in the support_files subfolder. That file may be edited as desired. In a future version of gbSnippets an option will be added which displays keywords exactly as given in the keywords.txt file.

Brace Highlighting

This feature highlights the matching parenthesis, ( or ), when the cursor is placed in front one of the character. An alternate highlighting is also applied if no matching parenthesis is found.

Indentation Guidelines

The code editor can display vertical lines that correspond to a standard indentation, which by default is 3 spaces. The vertical lines can help you align code, or it can help you scan code to find starting and ending lines of code pairs, such as If/End If.

AutoIndentation

When the user presses enter, the cursor will be placed at the same level of indentation as the line where enter was pressed. However, if the line begins with one of several code constructs, indentation will be made one level lower than the current line.

Code constructs which result in extra indentation include:

   If             For
   Else           Do
   Select         Loop
   Case           While

Call Tips

When a PowerBASIC function is typed in by the user, the text editor can display a popup label containing a list of the arguments allowed by the function. Some examples of call tips are shown in the image to the right.

When the popup label is displayed, the user continues typing, filling in the argument list per the displayed syntax. Pressing a space bar will remove the display.

The user may modify the list of functions that gbSnippets recognizes and the corresponding argument syntax/list that is displayed. See the three files words1.txt, words2.txt, and words3.txt in the support_files subfolder for more information.

AutoCompletion

PowerBASIC keywords are often used in combination with one another, such as "Control Add" or "Thread Get Priority". When the user types in a PowerBASIC keyword that is part of a combination, a popup list of allowed keywords needed to finish the combination, is displayed. The user can select from that list (press TAB) or simply continue typing.

The user may modify the list of keyword combinations that gbSnippets recognizes. See the two files members1.txt and members2.txt in the support_files subfolder for more information.

Code Folding

When reviewing code it can be convenient to hide the code within procedures and other code constructs. This is called folding and is demonstrated in the image below. Code constructs may be folded by clicking on the minus symbol in the margin, or unfolded by clicking on the plus symbol in the margin. The toolbar provides buttons for folding/unfolding all constructs in a snippet.

The code constructs which gbSnippets supports are:

   Type        End Type                 Class       End Class
   Macro       End Macro                Interface   End Interface
   Sub         End Sub                  Method      End Method
   Function    End Function             Property    End Property
   Callback    End Function             Union       End Union

In general, folding can also be applied to lesser structures, such as Select/End Select. gbSnippets may support that level of folding in the future, depending on the level of support from users.

Code Insertion

gbSnippets allows you to select a block of code from the editor, give the block a name, and save the block into a "procedure library". Any block of code in the procedure library can then be inserted into the editor at the cursor. The text editor context menu provides the two options which support this feature.
  • Add Selection to Procedure Library
  • Insert Procedure

Although it's called a "procedure" library, any selected block of text can be stored in the library, which is simply a text file named "procedures.txt" which is found in the "support_files" subfolder.

Simply select some text in the editor and pick the "Add Selection ..." menu option in the text editor context menu. A prompt will ask for the name by which to list the code block in the library.

To insert a block of text at the cursor, just select the "Insert Procedure" menu option from the text editor context menu to see the list of code blocks found in the library. Click on a code block name to insert the code into the text editor. The Code blocks are listed alphabetically.

The procedure library file can be edited manually to make more extensive changes, such as deleting code blocks, to the procedure library. The code block format will be obvious when you open the file.

The procedure library comes with a dozen or so entries that I find myself using in many of my applications.

Support File Downloads

As mentioned above, most of the files that ship with gbSnippets are not updated as part of the online update because the user may have made changes to those files. So here are links to the files, which you can download and use to overwrite the existing files.

To save the files, use a right-mouse click on the links.

Here are links to the files found in the "snippets" subfolder.

Here are links to the files found in the "support_files" subfolder.

Comments/Suggestions

I welcome feedback on gbSnippets and its documentation. Please feel free to contact me with your comments or suggestions.