Calc sheets
Contents
- Overview
- How to use a calc sheet
- How to create a diagram
Overview
When working with database tables a common used data structure is an array
of values who's entries are of different type (integer, double or string).
Since this data structure appears in different places in HBasic I started
to set up a common representation for them. The calc sheet should be a visible
representation of this structure. A calc sheet could not only be used to display
and edit values within fields of the table, it may also keep expressions /
formulas in fields for which the value will be calculated every time some
entry in the sheet changes.
In a later version of HBasic it should be possible to
- create a database table from the calc sheet entries
- create a calc sheet from the table of a database
- create a calc sheet from the result of a query
- display diagrams from values of a calc sheet
- read or write the contents of a calc sheet to a file (import/export
data)
- use the values of a calc sheet as an input for a report
- Read or change values in a calc sheet from an HBasic program
How to use a calc sheet
To create a new calc sheet click on the New entry of the File menu
or the New button in the toolbar. A dialog pops up where you can select
the type of structure that you want to create. If you select the Calc-sheet
icon a new calc-sheet window with 100*100 empty cells will be created. You
may insert values into the fields of the calc-sheet by clicking on the field
and just inserting the text.
You can find an entry for each calc sheet that you have created in the project
tree. Each value that you have inserted into a field of a calc sheet will
be saved with your project. If you reload your project later the calc sheets
will be restored with there contents.
Expression fields
Beside simple values it is more interesting to store expressions (or formulas)
in a field. If you want to insert an expression into a field the first character
or the field text must be a '='. The main part of the expression may be set
up from values, oprators and field references. It should be possible to use
other methods, oprations or HBasic functions here later. An example of an
expression text may be B2 * D4 + 10. In this example B2 and D4 are field references
to the field in column named 'B' with row number 2 and column named 'D' and
row number 4.
After you have pressed the return key in the expression field the expression
text will be replaced with the value of the expression. Therefore HBasic tries
to replace referenced fields with the values of this fields. If a value could
not be evaluated (for example if the field is empty or holds a text) HBasic
will set the value of the field to 0. Afterwards the value of the resulting
expression will be calculated and displayed in the field of the calc sheet.
If for example the value of field B2 is 2 and the value of the field D4 is
4 the expression B2 * D4 + 10 will display the value 18.
If you want to edit an expression of a field click on the field with the
left mouse button. The expression of this field will now be displayed in an
editline at the top of the calc sheet window. You can edit the expression
at this place. If you click on this editline theexpression will also be copied
to the field of the calc sheet where you may also change it. After pressing
the return button the expression text will be replaced by the expression value
in the calc-sheet.
If an expression references other fields in the calc sheet the value displayed
changes if some of the referenced values will be changed. In the example above
you can change the value of the fields B2 or D4 and you will see that the
value displayed in the expression field will also change. This feature may
be used in many different ways as you can see in the spreadsheet examples
of other applications.
Currently the implementation of calc sheet is in an alpha state but it might
be interesting for other developers to see where they might help and for user
to know what might come in the neer future.
Diagrams
Diagrams are graphical representations of values in a calc sheet. Diagrams
can represent the values in different types of charts like line chart or bar
chart. To create a diagram select some values within a calc sheet within one
column. Click on the right mouse button and select Calc sheet. A
new window will be opened with the chart diagram. The diagram will be created
with default properties for the chart type. You may change this properties
by clicking on the toolbar buttons in the diagram window.
You may also print the resulting chart by clicking on the Print button
in the toolbar. The diagram / chart feature is also in an alpha state. More
properties should be implemented later. It will be possible to insert a chart
into a calc sheet or save and change it independant from the calc sheet.