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.
Feature List
gbTextDB provides basic operations for viewing and modifying the contents of the database.
OverView:
- All-text database content
- No external database engine (PowerBASIC statements/API only)
- Optional GUI elements - TreeView, Text Editor, Toolbar
- Standard file options (New/Open/Save/SaveAs)
- Database backup
- Database encryption (optional)
- Standard Record Edit Features: Edit/New/Add/Delete
- One binary data field per record (for storing attachments, such as images)
- One multi-line text field per record
- Search, including Boolean AND/OR and Whole Word options
- Automatic update of record modification date
- Font selection
- Select multiple records (Copy/Print/Delete)
- Export to CSV
- Event Support (birthdays, anniversaries, ...)
- Send email via default client
- Send Text Message via default email client
- Open URL in Editor
- Single instance limitation to protect database override
- Online EXE update
- Online Help
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.
- Category - sorts by Category, then Name
- Country - sorts by Country, then Name
- Date - sorts by Date, then Name
- Location - sorts by Location, then Name
- Attach - sorts by Attach, then Name
- Events - sorts by Events, then Name
- TextMsg - sorts by TextMsg, then Name
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
- Send Text Message
Using the selected record's phone number and text message carrier, gbTextDB can open the user's
default email client with To: filled out as needed to send a text message through the carrier's SMS gateway.
Toolbar Settings Button
- Confirm Delete
By default, the user must confirm deletion of records (one confirmation for all records).
Uncheck this setting to delete records without confirmation.
- AutoSave On Exit
By default, when closing gbTextDB, the user is asked to save any changes made during
the session. The AutoSave setting skips the confirmation and will automatically save
any changes when gbTextDB is closed.
- FileName in Title
Displays the database files name (just the Name-Extension, not the path) in the gbTextDB titlebar
- Double-Click To Edit
Toggles double click action on a ListView record - between opening the record in a View (read-only)
record dialog or opening the record in an Edit record dialog.
- On Top
Keeps gbTextDB displayed on top of all other desktop applications.
- Event Report on Startup
Displays an Event Report when gbTextDB is started.
- AutoUpdate From Editor
This menu option turns on automatic capture of record Editor changes.
By default, changes made in the record Editor are not captured. The user much manually
press the Apply toolbar button to save changes. This approach allows the user to work within
the record editor, essentially as a workspace, without having to worry that changes are
being captured. But with the AutoUpdate option turned on, all changes are captured immediately.
- Small Toolbar
Toggles the list of buttons shown in the toolbar. The list of buttons hidden is preset
and may not be changed by the user.
- Large Editor
Toggles the size of the record Editor between 200 and 300 pixels.
- Encrypt File on Save
Encrypts all future database Saves. It does not do an immediate encryption of the currently
opened database file.
- Show Toolbar
Toggles display of the Toolbar control
- Show Tree
Toggles display of the TreeView control
- Show Editor
Toggles display of the Editor (TextBox) control
- Online Update
Checks to see if a more recent version of gbTextDB is online. If so, allows the user to download
and install the latest version.
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
- 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
- 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)
- Apply
Applies the content of the record Editor to the current record
- View
Views the currently selected record using a popup View dialog
- Delete
Deletes all checked records
Attachments
- Attach File
Select a file to attach to the currently selected record
- View Attachment
View the attached file for the selected record
- Remove Attachment
Disassociates the record from any file attachment. The attached file remains
in the database binary file, but is not associated with any record
- Compact Attachment File
Remove all unattached files from the database binary file
Settings
- Confirm Delete
Requires the user to confirm deletion of records
- Auto Save On Exit
By default, when closing gbTextDB, the user is asked to save any changes made during
the session. The AutoSave setting skips the confirmation and will automatically save
any changes when gbTextDB is closed.
- FileName in Title
Displays the database files name (just the Name-Extension, not the path) in the gbTextDB titlebar
- Double-Click To Exit
Toggles double click action on a ListView record - between opening the record in a View (read-only)
record dialog or opening the record in an Edit record dialog.
- On Top
Keeps the gbTextDB window above all other desktop applications
- Event Report on Startup
Runs an event report whenever gbTextDB is executed.
- AutoUpdate From Editor
When selected, automatically captures changes made by the user in the record Editor control. Otherwise,
the user must press Apply to cature the current content of the record Editor.
- Small Toolbar
Toggles the list of buttons shown in the toolbar. The list of buttons hidden is preset
and may not be changed by the user.
- Large Editor
Toggles the size of the record Editor between 200 and 300 pixels.
Actions
- Copy Selected Record
Copies the currently selected record to the clipboard
- Copy Checked Records
Copy all checked records to the clipboard
- Copy All Records
Copy all database records to the clipboard
- Print Checked Records
Print all checked records
- Send Email
Open default email client, with email addressed to the email address of the selected record
- Send Text Message
Open default email client, with email addressed to the smsgateway (phonenumber@smsgateway)
- Select Font
Select a font to be used by the TreeView, ListView, and Editor controls
These additional menu items are common to the ListView/TreeView controls:
- Find
Open the FIND dialog
- Encrypt File On Save
Turns on encryption (
- Show Toolbar
Toggles display of the Toolbar control
- Show Tree
Toggles display of the TreeView control
- Show Editor
Toggles display of the Editor (TextBox) control
- Online Update
Checks to see if a more recent version of gbTextDB is online. If so, allows the user to download
and install the latest version.
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.
- Expand All Nodes
Expands all category nodes in the TreeView
- Collapse All Nodes
Collapses all category nodes in the TreeView
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.
- Check All
Check all records currently in the ListView control
- UnCheck All
UnCheck all records currently in the ListView control
- Confirm Delete
Toggles requirement for user to confirm deletion of ListView records.
Editor Context Menu
These options are available from the built-in record Editor context menu:
- Copy
Copy selected text to the clipboard
- Cut
Cut the selected text from the Editor, and place on the clipboard
- Paste
Paste clipboard text at the caret in the Editor
- Delete
Delete the selected text from the Editor
- Apply
Update the currently selected record with the content from the Editor
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:
- F1 - Help
- F3 - Find dialog
- Ctrl-B - View binary attachment in default client
- Ctrl-D - Delete selected record
- Ctrl-Delete - Delete selected record
- Ctrl-E - Show built in record Editor
- Ctrl-F - Find dialog
- Ctrl-H - Toggle display of Toolbar
- Ctrl-L - Show all database records in ListView control
- Ctrl-M - Display popup dialog with full record information
- Ctrl-N - Add a new record (shows an Add popup dialog)
- Ctrl-P - Print checked records
- Ctrl-R - Reset ListView column widths to default values
- Ctrl-T - Run text code
- Ctrl-Z - Toggle debug print statements
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!