gbTextDB

gbTextDB II is a database application which uses PowerBASIC statements and API to implement all database operations. gbTextDB demonstrates that implementing a database need not depend on the use of commercial database engines, such as SQL.

One of the key features of gbTextDB is that the database format consists entirely of text content, one line per field of each record. This allows a user to open and edit the database using text editing applications of their choice.

In addition to basic view/edit/search features, gbTextDB supports storing binary data with each record, includes a multi-line field for each record, provides a TreeView-based category view of record, and allows multiple methods for editing record data. Popup dialogs are also available for editing, adding, and viewing individual records. A FIND dialog is also provided.

Download (v2.54, 299K)

Feature List

gbTextDB provides basic operations for viewing and modifying the contents of the database.


Using gbTextDB

Typically, a list of all records is displayed in a ListView control. Records can be sorted on any field.

Records may also be displayed in a TreeView, separated by "category". The TreeView and ListView selections are synchronized, i.e., they contain the same records and the same record is selected in both controls.

Records may be edited in two ways, using a popup Edit dialog or using a record editor (TextBox) that is displayed to the right of the ListView control. Popup record dialogs can also used to add new records or to view existing records. Changes made using a popup dialog automatically update the corresponding records, whereas changes made using the record editor are not saved unless explicitly directed by the user.

Searches are always made against the entire database, with matching records displayed in both the ListView and TreeView controls. The display can be refreshed to show all records in the database at any time.

Only one instance of gbTextDB is allowed. If you attempt to open a 2nd instance, the 1st instance will become active.

Here's a summary of the primary features available in gbTextDB ...

File Actions
Open, New, Save As, Save, Backup, Encryption

Record Actions
Edit, Add, Delete, View

Search Options
Boolean AND/OR search

Record Actions
Export to CSV, Copy, Print, Email, Events

Internet Actions
Send Email and Text Message via user default email client

GUI Elements
ListView (record list, search result list)
TreeView (category view)
Toolbar (actions/settings)
TextBox (built-in record editor)
Popup Record Dialogs (edit/add/view individual records)
FIND Dialog (boolean searches across all fields)


Useful GUI Configurations

The use of optional GUI elements allows the user to adjust the display to meet their personal approach to working with records in the database. These next images show several GUI configuration images which are possible with gbTextDB.

In the cases of minimal GUI elements, context menus allow the user to access the same set of commands as is available from the gbTextDB toolbar. So regardless of which GUI elements are visible, the user has full access to all gbTextDB features.

First field of ListView only:

First field of ListView only + Record Editor:

TreeView only:

TreeView + Record Editor only:

Limited fields of ListView record list:

Record list showing all fields and Toolbar:

ListView and TreeView - all fields and category view:

ListView, TreeView and Record Editor:

ListView, TreeView, Record Editor and Small Toolbar:

ListView, Toolbar and multiple popup view-only record dialogs:

All GUI elements:

Record Edit Options
For those configurations above which do not include the built-in record editor, the user can double-click on a record to display the popup Edit dialog. The popup Edit dialog and the built-in record Editor are shown side-by-side in this next image:


Database Format

Record content is stored as text. There are 12 fields stored in the database, one field per line of text. The number of allowed characters in each field is given to the right of the field name in the following table:
   Name                         (35)   
   Phone                        (15)
   Email                        (35)
   Text Message Carrier         (10)
   Location                     (50)
   Country                      (35)
   Category                     (35)
   Events                       (100)
   Node                         (15)
   Attachment Name              (50)
   Attachment Start Position    (15)
   Attachments End Position     (15)
   Date Last Modified           (20)
   Display Status               (1)
   Unused Field                 (20)
   Unused Field                 (20)
   Unused Field                 (20)
   Blog                         (500)

The Blog field is a multi-line field, consisting of lines of text separated by a $CRLF character delimiter. However, when stored in the database, $CRLF is replaced with a Chr$(7) in order to store the field on a single line of text (as a text editor would view it).

Conversely, when viewed within gbTextDB, the Chr$(7) characters are replaced with $CRLF character pairs.

The Attachment Start/End Position elements cannot be assigned by the user. They are automatically filled when a file is attched to a record. Likewise, the Date Last Modified is not directly edited by the user. It is automatically updated when the user modifies a record.


Record Editing/Viewing

There are two ways in which to edit records - using the popup Edit/Add record dialogs, or using the built-in record Editor.

Edit/Add Record Dialogs
The toolbar provides options to edit or view existing records. A toolbar button is also available to add a new record to the database and then display that record for editing. Here are the three popup dialogs used for the edit, add, and view functions:

Note that the View dialog is set to read-only, and Save is disabled.. The Edit dialog contains the information from the record being edited. The Add dialog contains default information for the new record.

Any number of View popup dialogs can be displayed. This is useful when wanting to compare record information, where the records are far apart in the displays lists.

However only one Edit or Add popup dialog can be used at a time. This is necessary to avoid the possibility of overlapping data or unresolved commands, depending on actions taken by the user.

The user can also set gbTextDB to edit or view a record (display the popup dialogs) by double-clicking on the record in the ListView or TreeView controls.

Edit/Add Record Dialogs
An optional built-in recrod Editor (textbox) is also available. With the Editor, the user just edits the content of a record in a multi-line textbox. To the left of the editor are labels showing what goes in each line.

If AutoUpdate From Editor is set, changes made by the user are immediately captured and displayed in the TreeView/ListView controls. Otherwise, the user must press Apply from the toolbar to capture the current content of the record Editor.


Attachments

gbTextDB allows a user to associate a file with each record in the database, and maintains a copy of that file in a second, binary database file. The binary database file has the same name as the text database file, plus an extension of ".bin".

If no files are associated with any record of the database, the binary file is not created and is not required to view the database.

New attachments are simply appended to the binary file, with the start/end positions saved for the associated record.

When files are removed from a record, the start/end position of the record is simply zeroed out. THe previously attached file is still contained in the binary file, but is no longer associated with any record.

A compact function is provided to periodically remove any unattached files from the database binary file.

To view an attachment, gbTextDB creates a copy of the binary content in a temporary folder, then opens the file in the user's default client for that file type. The temporary file uses the filename/extension of the associated file (no original path information).


Sorting

Database records may be sorted by clicking on the ListView column headers. Each header click alternative the sort between ascending and descending sorts.

These column headers are used to sort on both a primary and secondary column.

All other headers sort only on the single header field.

The "Pos" and "Node" headers do not provide a sort, as this data would be changed by process of sorting. Pos is the current position of the record in the internal record array. Node is the handle to the TreeView node containing the record.


Encryption

gbTextDB allows encryption of the database text file, but not the binary companion file (if one is used). When the toolbar Encrypt button is pressed, all future Saves of a database requires the entry of a password by the user.

gbTextDB accepts any character string for a password. There's no built-in requirement to provide a "strong" password. It's up to the user to decide the password length, character makeup, etc.

When encryption is applied to a database, the first byte of the databse is set to the character "e". The first byte of an un-encrypted database files is set to the character "-".

gbTextDB uses a simple XOR encryption. If you want better security, I highly suggest that you replace the EncryptText() function with a function of your own.


Events

gbTextDB supports an "Events" field, in which multiple events may be stored. In addition to simply editing events, a summary report is available which shows the events on the current day, as well as +/- five days to either side of the current date.

Events are entered as string pairs, such this:

   Bday 09-12-1951

The first string gives the event name and the second string gives the event date. Only the month/day (9-12 in the example above) is used to generate the Event Report (image above). The Julian date of the event (using the extracted month/day plus the current year) is used to compare against today's date.

Name strings may not include spaces. Date strings must be of the MM-DD-YYYY character format, as shown in the example above. gbTextDB will accept any event string, but the Event Report will work on with the format just described.


Toolbar

The following features are available from the gbTextDB toolbar. And, since the Toolbar may be hidden, these features are also available from the ListView and TreeView context menus.

  • Open
    Opens an existing database. Allows user to saves changes to the current database

  • New
    Creates a new database. Allows user to saves changes to the current database

  • Save
    Saves the current database content to the database file without asking for user permission

  • Save As
    Allows the user to save the current record content to a new file

  • Edit
    Edits the currently selected record using a popup Edit dialog

  • Add
    Adds a new record to the database (placed at the end of the record list)

  • Delete
    Deletes all checked records

  • View
    Views the currently selected record using a popup View dialog

  • Attach
    Allows the user to select a file to attach to the currently selected record

  • Apply
    Applies the content of the record Editor to the current record

  • List All
    Displays all records in the ListView control

  • Find
    Opens a FIND dialog in which the user enters a search term. After a search, all matching records are displayed in the ListView and TreeView controls. See the section below for more information on searches.

  • Copy (Selected)
    Copies the selected record to the clipboard

  • Copy (Checked)
    Copies all checked records to the clipboard

  • Print
    Prints all checked records

  • Email
    Open default email client, with email addressed to the email address of the selected record

  • Events
    Displays the Event Report. All database records are used in the report, not just those records lists in the ListView.

  • Font
    Opens to the font selection dialog. The selected font is applied to the ListView, TreeView and Editor controls.

  • Editor
    Enables display of the record Editor control, which is a textbox placed to the right of the ListView control. The Editor provides an alternative to the popup Edit dialog.

  • Tree
    Enables display of the TreeView control

  • Encrypt
    Enalbel encryption when databse files are saved

  • Settings
    Cycles display of the TreeView and record Editor controls. If neither or only one control is pressed, both are displayed. If both are currently displayed, then both are hidden. The dropdown arrow presents a context menu for setting various gbTextDB options.

  • Help
    Opens this online Help file. Additionally, the dropdown arrow associated with the Help button provides the following dropdown menu option:


    Toolbar Context Menus

    The SaveAs and Settings toolbar buttons provide dropdown menus, as follows:

    Toolbar SaveAs Button

    Toolbar Email Button

    Toolbar Settings Button


    ListView/TreeView Context Menus

    The TreeView and ListView context menus (shown in the next image) contain many common menu items. These context menus replicate the features available from the toolbar, so that when the toolbar is hidden (as is the user's option), the full feature gbTextDB feature set continues to be available.

    Note: the TreeView context menu only displays when the user right-mouse clicks on a name - not on a category!

    The common menu items are discussed first, followed by a discussion of the menu items which differ between the two context menus.

    File

    Edit
    Attachments
    Settings
    Actions

    These additional menu items are common to the ListView/TreeView controls:

    Unique TreeView Context Menu Items
    In addition to the common context menu items, these addition menu items are displayed as part of the TreeView context menu.

    Unique ListView Context Menu Items
    In addition to the common context menu items, these addition menu items are displayed as part of the ListView context menu.


    Editor Context Menu These options are available from the built-in record Editor context menu:


    FIND Dialog

    The Find dialog may be opened by pressing the Find toolbar button or the Find menu item on the TreeView/ListView context menus. F3 and Ctrl-F may also be used to open the Find dialog.

    Following a search, the ListView and TreeView controls will list only those records matching the search. To return to a listing of all records in the database, just press the "List All" toolbar button, or use the Ctrl-L shortcut.

    The FIND dialog opens with the most recent search term displayed. Simply press the Search button to initiate a search. Pressing ENTER in the searchterm term textbox will also initiate a search.

    By default, searches are case insensitive. Check the case sensitive check box to make Searches case sensitive.

    The search string entered may consist of more than one word. Select the AND/OR/String FIND dialog settings to determine if the string is searched for, or if the words in the string are searched for as AND (all words must be found for a record to match) or OR (any word must be found for a record to match).


    Keyboard Shortcuts

    The following key combinations are available to the user to access gbTextDB features:


    Other Comments

    Miscellaneous information is provided in this section.

    Sessions
    When gbTextDB starts, it restores the previous session content.

    INI File
    gbTextDB application settings are saved in an INI file, kept in the same folder as the gbTextDB application.

    Misc Comments
    Here are a few other comments regarding the operation of gbTextDB.

    Checks are not saved between sessions.

    There is no undo.

    SORT/FIND/View All actions results in the FileChanged flag being set, requiring the user to confirm saving the database when a session is closed.

    Actions causing setting of the FileChange flag also include, deleting a record, building a fake database, adding a record, editing a record, attaching a file, or removiung an attachment.

    The FileChange record is reset when the database is saved, saved to file, an existing database is reopened or a new database is created.

    Comments and suggestions are welcome!