I can get my dropdown list to populate using the following, and numbers.
However, when I try to use the StrPrintF(...) function to fill the list with
strings instead of numbers, it crashes.
I know it must be something simple, but I don't notice it.
/***********************************************************************
*
* FUNCTION: vnoDrawList()
*
* DESCRIPTION: Draws the dynamic dropdown list
*
* PARAMETERS: - frm
*
* RETURNED: nothing
*
***********************************************************************/
void vnoDrawList(FormPtr frm)
{
ListPtr lst;
tblPackedPvnoPtr p;
tblPvno thePvno;
VoidHand record;
char *pStr;
UInt numRecords;
UInt index;
// Get a count of the records in the database
numRecords = DmNumRecords(gPvnoDB);
// If there are records in the database
if(numRecords)
{
// Get a handle to the list object from the form
lst = GetObjectPtr(NfoGeneralVehicleNumberList);
gStringsBlock = MemPtrNew(numRecords * 3);
// Query each record in the database
for(index = 0, pStr = gStringsBlock; index < numRecords; index++,
pStr++)
{
// Query the Record
record = DmQueryRecord(gPvnoDB, index);
// Lock the record and unpack it
p = MemHandleLock(record);
UnpackPvno(&thePvno, p);
// Create the list of strings **** HERE
pStr += StrPrintF(pStr, "%s", thePvno.VehicleNumber);
// Unlock the record
MemHandleUnlock(record);
}
// Create an array of strings
gStringArrayH = SysFormPointerArrayToStrings(gStringsBlock,
numRecords);
// Set the List Choices
LstSetListChoices(lst, MemHandleLock(gStringArrayH), numRecords);
}
}
+++++++++++++
Timothy D. Astle
Embedded Systems Programmer
ALT Group Inc.
+++++++++++++
"People who can smile when things go wrong has thought of someone else to
blame it on."
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/