Chapter 3. Data sensitive methods

Table of Contents

Objects of type hk_dsvisible - the class hk_datasource
Objects of type hk_dsdatavisible - the class hk_column
Objects of type hk_presentation - forms and reports
Handling forms
Handling reports

Before we start writing programs, we will first have some theory. Below you see the (c++)- structure of hk_classes. There are classes that handle the contact to the database (see the left side of the graphic), while others handle the interaction with the user (we have already seen the hk_visible class in the previous section).

Figure 3.1. hk_classes overview

hk_classes overview

Figure 3.2. description of the most important classes

description of the most important classes

Objects of type hk_dsvisible - the class hk_datasource

All data-sensitive objects are of type hk_dsvisible (or its child hk_dsdatavisible). hk_dsvisible inherits from hk_visible. The most important method of hk_dsvisible is datasource(). This method returns a class of type hk_datasource, representing the whole datasource (either a table or a query)

Figure 3.3. hk_datasource methods

name()

returns the name of the datasource

goto_row(rownumber)

moves the row selector (row cursor) to 'rownumber'

goto_first()

goto_last()

goto_next()

goto_previous()

row_position()

returns the row number of the current row

max_rows()

returns the total number of existing rows

enable()

disable()

set_enabled(e)

is_enabled()

hk_column*column_by_name(name)

returns an hk_column object of the column with the name 'name'

store_changed_data()

hk_database*database()

The following example shows how to move between rows in a datasource. For this, create a button in the form and set a datasource. Add the script to the "On click"-action.

Example 3.1. rowposition

ds=hk_this.datasource()
ds.goto_row(ds.row_position() + 2)

How to get a specific hk_column object can be seen in the following example. For what you can do with this object, please see the next chapter.

Example 3.2. find a specific column

col=hk_this.datasource().column_by_name("author")