|INM V12 Database for Director||Windows, Macintosh||Interface and data-handling||3.x Regular & Light|
It can be useful to allow a user to scroll database values in a field on the screen. This technote shows and explain a convenient way of displaying multiple fields of a V12 Database selection in multiple scrolling Director members while keeping them properly aligned and synchronized when the user browses through the selection.
The secret resides in a clever use of mGetSelection. A single global variable is used to keep track of the number of the first record to display in the scrolling fields. For instance, let's imagine we have a "gTable" table opened, with two fields that we would like to scroll, "clothes" and "color".
First, we'll need two handlers that will create the selection each time the user clicks on an up or down arrow. The variable "gFirstRec" represent the first record to be shown.
-- Scroll one record up and refresh display
if (gFirstRec = 1) then exit
set gFirstRec = gFirstRec - 1
-- Scroll one record down and refresh display
if (gFirstRec >= mSelectCount(gTable) ) then exit
set gFirstRec = gFirstRec + 1
Next, the handler that will refresh the screen should look like the following script. The variable "kPageLenght" is a constant that remembers the number of record to show, depending on the field's height.
-- Show kPageLength records of the current selection, starting at record number gFirstRec
-- gTable must be valid upon entry of this handler
put mGetSelection(gTable, "LITERAL", gFirstRec, kPageLength, TAB, RETURN, "clothes") into field "clotheslist"
put mGetSelection(gTable, "LITERAL", gFirstRec, kPageLength, TAB, RETURN, "color") into field "colorlist"
To better comprehend this example, we recommend that you download the [free] sample available below and note that the scripts contained within are easily reusable in any Director movie!
This sample is supported on Director 6.5 and later.