Edgar T. López wrote:

Dear Bob,
Thank you for your help, I already found your source code, however I do not
understand how to use it with my code yet.
I have a function called "FindDatabases" and after execute this one, I get
an array with the names, ID and CardNo, for example:

typedef struct InformationDB{
char Name[dmDBNameLength];
LocalID ID;
UInt16 NoCard;
}InformationDB;

static InformationDB *gDBEltec;
You haven't defined any memory space for your structure yet. Since there are 3 elements, all of the same size, might you do something like this...

gDBEltec=MemPtrNew(3*sizeof(InformationDB));

...but probably you will need to be more dynamic than that.  You would 
determine the number of entries, and create the memory chunk based on that 
number of instances of your structure.

gBDEltec[0].Name = "16/06/05 14.10.01" ,   gBDEltec[0].ID = any value,
gBDEltec[0].NoCard = 0
gBDEltec[1].Name = "16/06/05 14.11.20" ,   gBDEltec[1].ID = any value,
gBDEltec[1].NoCard = 0
gBDEltec[2].Name = "16/06/05 14.12.13" ,   gBDEltec[2].ID = any value,
gBDEltec[2].NoCard = 0

I know that the Comparison function return 0 if the two strings are equal, a
positive value if the first string should be after the second string
alphabetically and negative value if first string should be before the
second string. But I don´t know how to fill the parameters of SysQSort.

This is part of you code:
SysQSort(dbListP,dbCount,sizeof(myDbListType),myCompareDBNames,0);

Would you mind to tell me how to fill the first and third parameter
according to my code?
The first parameter is simply a pointer to the beginning of the memory chunk of your data. The 3rd is the size of EACH part of that data. The data must be divided into equal sized pieces. So for the data you presented, the function should probably look like this:

SysQSort(gBDEltec,3,sizeof(InformationDB),myCompareDBNames,0);

The pointer has to be valid for the sort command, so you can't dispose of the 
pointer in one function then try to sort it in another.

Bob



--
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to