
Programming i!-Database Plus
16
i!-Database Plus and DBWizard
The next section creates some variables you will need. Create a
DEVCHAN
set to hold the buttons
which control the movement through the list. This action can be seen when you get to the
DEFINE_EVENT
section below.
(***********************************************************)
(* VARIABLE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_VARIABLE
_sDB_LISTBOX sTitleListBox
DEVCHAN dcTITLES_CTRL[] = {
{ dvTP,11 }, { dvTP,12 }, { dvTP,13 }, { dvTP,14 },
{ dvTP,15 }
}
The next section creates a display call to display our results. This function is called whenever
TITLE
data is processed from the server in your
DATA_EVENT
. An array of structures will be passed
containing the data and an
_sDB_LISTBOX
structure. The listbox structure will contain information
about the number of records and from what location they have started.
Basically, loop over the valid number of records and display the data you are interested in. There
are two Send_Command's that send Artists and CD Title information to our touch panel. The next
loop is used for clean up. Continue looping up to the display size, which is the total number of
items that can be displayed, and clear out the variable text. The last bit of code uses information
contained in your listbox. The first Send_Command displays record information in the form
displaying 1 - 10 of 100. The listbox also has a value you can send to a slider to represent the
current position in the list, like a scroll bar. The last code copies the listbox to the listbox variable
you defined. A template for this function is generated by DBWizard and included in the include
file. The easiest way to write this function is to copy it from the .axi file and add any customizations
required.
(***********************************************************)
(* SUBROUTINE DEFINITIONS GO BELOW *)
(***********************************************************)
(*********************************************)
(* NAME: DB DISPLAY TITLES *)
(***************************************************************************)
(* Display a page of TITLES data *)
(***************************************************************************)
DEFINE_FUNCTION DB_DISPLAY_TITLES(_sDB_TITLES sDB_TITLES[],_sDB_LISTBOX
sTempListBox)
LOCAL_VAR
INTEGER nLOOP
{
(* The following are elements of the structure where nLOOP=1 to nCOUNT: *)
FOR (nLOOP = 1; nLOOP <= sTempListBox.nCOUNT; nLOOP++)
{
(*
SEND_STRING 0,"'strArtist=',sDB_TITLES[nLOOP].strArtist"
SEND_STRING 0,"'strCopyright=',sDB_TITLES[nLOOP].strCopyright"
SEND_STRING 0,"'strLabel=',sDB_TITLES[nLOOP].strLabel"
SEND_STRING 0,"'strReleaseDate=',sDB_TITLES[nLOOP].strReleaseDate"
SEND_STRING 0,"'strTitle=',sDB_TITLES[nLOOP].strTitle"
SEND_STRING 0,"'slTitleID=',ITOA(sDB_TITLES[nLOOP].slTitleID)"*)
(* ADD DISPLAY CODE HERE *)
SEND_COMMAND dvTP,"'!T',0+nLOOP,sDB_TITLES[nLOOP].strArtist"
SEND_COMMAND dvTP,"'!T',10+nLOOP,sDB_TITLES[nLOOP].strTitle"
Continued