New features in build 0.9.6
Contents
The HBasic object model
With the HBasic package manager you may load components like Qt widgets
that have been developed with C++ code and exported as a shared library.
This components allow you to access the properties, methods and events
of the loaded components within the HBasic sourcecode. With the new
object model I want to implement the same capabilities for the data
structures of the HBasic IDE and the data within your project.
This means if all this changes have been implemented you may list or
change the properties of your forms, widgets or for example the project
database with HBasic sourcecode statement or call methods that will
normally be started with a mouseclick on an entry in the menubar.
Therefore the old data structures and the access methods will be changed
step by step to the new model so don't expect this new version to be
complete and stable in version 0.9.6. When it's ready you may find
substructures like forms and its subwidgets, databases, reports, queries
and sql-statements but also elements of the IDE like menu amd toolbars
or commands normally started with a mouseclick in the object model
ready for using it from the code.
Let me give you a simple example how it looks like to call a command in
the new object model. Commands are a substructure of the main
application object and represent actions that will normally be started
from the menubar and toolbar entries of the IDE. The currently available
objects in the HBasic object model can be displayed as a tree structure
starting with a base application object. Substructures of the
application object are lists of commands, databases and project
definitions. Elements in this list may export properties and methods to
access and edit this structures or may have sublists themselfes. Each
project in the project currently exports it's list of icons, queries,
sheets and SQL statements. Remember there's more to come in following
versions to implement full access to the project tree.
Application (substructures)
- commands
- databases
- projects
-- icons
-- queries
-- sheets
-- reports
-- SqlStatements
Displaying the object model in the
package manager
To get an overview which objects may be used in the current version of
HBasic there is a new subentry in the package manager called HBasic
objects. If you click on this entry in the package list all subentries
of the main application object will be displayed in the Component list
window. If you click on one subentry like commands you can see a list of
the available entries in the commands list in the Member list window on
the right side.
If the subentries of a list like projects have also subentries you can
switch to them with a doubleclick on one entry in the Member list
window.
- Mouseclick on "PROJECTS" in Component-list displays all available
project names in member list
- Double click on entry like "Project1" displays substructures of
this project
The LineEdit widget above the component list displays your current
"access path" in the object tree. The a mouseclick on the button to the
left side guides you one step up in this tree (displays the application
substructures in the example).
Using macros to access objects
Editing structures in you current project through HBasic objects
normally should be executed immediatly without starting the compiler for
all forms and sourcecodes. To implement this it is now possible to add
source code blocks that will be called macros. Since macros are
independent of forms that will be opened at runtime you have to add a
global sourcecode document to your project to insert macro sourcecode
definitions. Click on the project entry in the project tree window with
the right mouse button and select "New global source" to create a new
global source document.
A macro definition looks like a subroutine definition. It starts with
the keyword Macro and ends
with the keywords End Macro. In
our example we want to start the command called ShowAboutDlg from the
application object. This command represents the method opening the
dialog which will normally be displayed whenever you click on the
"About HBasic" menu entry in the menutree. To start a command every
command object has a method definition called exec that may be used to
start command execution. To start this exported method definition
insert the following sourcecode into the source-code window for a
global source document.
Macro mcrShowAbout()
commands( "ShowAboutDlg" ).exec()
End Macro
Starting macros
If you want to execute a macro you have to reference it's name.
Therefore HBasic has a new window to display the list of defined macros.
You can open the macro list with a mouseclick on the menu entry "View
macros" or the appropriate toolbar button. The macro window will display
the list of all macro definitions it could find in the sourcecode. If
you have added a new macro definition to your sourcecode you have to
reopen the macro window to update the list of available macros names.
To start a macro select it's name and click on the "Execute" button or
double click on the macro name in the window. In our example this will
popup the HBasic about dialog.
Using cell properties in sheet designer
If you have opened a sheet window you may now set some properties for
the sheet in the normal property editor. Properties may be used to set
the background or text color of a cell, to define the font of the cell
text or the color, position and line style of the border lines. This is
currently not very comfortable and will be extended in future releases.
It could also currently only be used for single cells. The following
image shows an image of a sheet where some properties for cells have
been changed. The second image shows the property editor window
displaying the properties of a sheet cell.
Message window
The new message window may be used by HBasic to display messages of
successful finished actions or error messages. Currently this messages
will be displayed with popups or in the status bar. This window may be
helpful to display the history of messages and maybe some more
detailed information subentries. Currently you may only open or close
the message window with an appropriate menu or toolbar entry.
Direct window
The direct window should be used to display output of the Print
statement for sourcecode which doesn't have an appropriate form to
display it's output. It may also be used to let you input commands which
may be executed immediatly like a command line.
HBasic editor in sheet designer and
report designer fields.
In older versions of HBasic the editor to insert sheet field functions
and the editor to define the output of report fields could only handle
some simple text strings. Starting with version 0.9.6 this has been
changed to handle the text like HBasic sourcecode expressions. This
expressions could use all features of the HBasic sourcecode like calling
methods defined in the HBasic source or in shared components. The code
to parse this expressions and the features like code completion must
only be implemented once and could be used in different contexts this
way. There are some bugs in the code for the 0.9.6 versions but some
didn't want to wait longer for a new HBasic version so that this bugs
will be fixed in the next version.