Problem appending text | developer.brewmp.com Problem appending text | developer.brewmp.com

Developer

Problem appending text

Forums:

Hi, I'm trying to convert an uint into a WSTR to append it into another WSTR to display it into an ISTATIC Text...

The code is this:
...
starting_record = 1;

while(starting_record <= nRecords)
{
pIDBRecord = IDATABASE_GetNextRecord(pIDatabase);
if(pIDBRecord != NULL)
{
if ((fieldType = IDBRECORD_NextField(pIDBRecord, &fieldName, &fieldLen)) == AEEDB_FT_WORD)
{
if ((checkup = IDBRECORD_GetFieldWord (pIDBRecord, &score_value)) == TRUE)
{
FLOATTOWSTR(score_value, scoreConverted, sizeof(scoreConverted));
WSTRCAT(scoreCompleto, scoreConverted); }
}
}
...

The loop is working fine, I get every score from the Database, the problem is on these two command lines:

FLOATTOWSTR(score_value, scoreConverted, sizeof(scoreConverted));

and

WSTRCAT(scoreCompleto, scoreConverted);

The last one crashes the emulator, I'd like to know why this is happening...

The definitions are:
...
uint16 score_value = 0;
AECHAR scoreConverted[10];
AECHAR scoreCompleto[100];
...

Thank you.

I'm not 100% sure, but I remember seeing some arrays not being properly zero-initialized...
Just in case, try MEMSET( scoreCompleto, 0, 100 ); just after the declaration..

I'm not 100% sure, but I remember seeing some arrays not being properly zero-initialized...
Just in case, try MEMSET( scoreCompleto, 0, 100 ); just after the declaration..

Hi bulach,
I added:
MEMSET( scoreCompleto, 0, 100 );
MEMSET( scoreConverted, 0, 10 );
before inserting values on these arrays, and inside the block below I added:
DBGPRINTF("Score: %d",score_value);
Having:
...
if ((checkup = IDBRECORD_GetFieldWord (pIDBRecord, &score_value)) == TRUE)
{
DBGPRINTF("Score: %d",score_value);
FLOATTOWSTR(score_value, scoreConverted, sizeof(scoreConverted));
WSTRCAT(scoreCompleto, scoreConverted); }

...
So while it gets the values of the score and puts it on the other array it prints on debug each score value, having:
Score: 29
Score: 26
Score: 25
Score: 24
Score: 23
Which is right.
After the loop is finished I make it display what is inside the array, and I get:
scoreCompleto[0]: 32
scoreCompleto[1]: 32
scoreCompleto[2]: 32
scoreCompleto[3]: 32
scoreCompleto[4]: 32
scoreCompleto[5]: 32
scoreCompleto[6]: 32
scoreCompleto[7]: 32
scoreCompleto[8]: 32
scoreCompleto[9]: 32
scoreCompleto[10]: 32
scoreCompleto[11]: 32
scoreCompleto[12]: 32
scoreCompleto[13]: 32
scoreCompleto[14]: 32
scoreCompleto[15]: 32
scoreCompleto[16]: 32
scoreCompleto[17]: 32
scoreCompleto[18]: 32
scoreCompleto[19]: 32
scoreCompleto[20]: 32
scoreCompleto[21]: 32
scoreCompleto[22]: 32
scoreCompleto[23]: 32
scoreCompleto[24]: 32
scoreCompleto[25]: 32
scoreCompleto[26]: 32
scoreCompleto[27]: 32
scoreCompleto[28]: 32
scoreCompleto[29]: 32
scoreCompleto[30]: 32
scoreCompleto[31]: 32
scoreCompleto[32]: 32
scoreCompleto[33]: 32
scoreCompleto[34]: 32
scoreCompleto[35]: 32
scoreCompleto[36]: 32
scoreCompleto[37]: 32
scoreCompleto[38]: 32
scoreCompleto[39]: 32
scoreCompleto[40]: 32
scoreCompleto[41]: 32
scoreCompleto[42]: 32
scoreCompleto[43]: 32
scoreCompleto[44]: 32
scoreCompleto[45]: 0
scoreCompleto[46]: 0
scoreCompleto[47]: 0
scoreCompleto[48]: 0
scoreCompleto[49]: 0
scoreCompleto[50]: 0
scoreCompleto[51]: 0
scoreCompleto[52]: 0
scoreCompleto[53]: 0
scoreCompleto[54]: 0
scoreCompleto[55]: 0
scoreCompleto[56]: 0
scoreCompleto[57]: 0
scoreCompleto[58]: 0
scoreCompleto[59]: 0
scoreCompleto[60]: 0
scoreCompleto[61]: 0
scoreCompleto[62]: 0
scoreCompleto[63]: 0
scoreCompleto[64]: 0
scoreCompleto[65]: 0
scoreCompleto[66]: 0
scoreCompleto[67]: 0
scoreCompleto[68]: 0
scoreCompleto[69]: 0
scoreCompleto[70]: 0
scoreCompleto[71]: 0
scoreCompleto[72]: 0
scoreCompleto[73]: 0
scoreCompleto[74]: 0
scoreCompleto[75]: 0
scoreCompleto[76]: 0
scoreCompleto[77]: 0
scoreCompleto[78]: 0
scoreCompleto[79]: 0
scoreCompleto[80]: 0
scoreCompleto[81]: 0
scoreCompleto[82]: 0
scoreCompleto[83]: 0
scoreCompleto[84]: 0
scoreCompleto[85]: 0
scoreCompleto[86]: 0
scoreCompleto[87]: 0
scoreCompleto[88]: 0
scoreCompleto[89]: 0
scoreCompleto[90]: 0
scoreCompleto[91]: 0
scoreCompleto[92]: 0
scoreCompleto[93]: 0
scoreCompleto[94]: 0
scoreCompleto[95]: 0
scoreCompleto[96]: 0
scoreCompleto[97]: 0
scoreCompleto[98]: 0
scoreCompleto[99]: 0
but nothing is displayed on the IStatic when I display it.
Any help ?

Hi bulach,
I added:
MEMSET( scoreCompleto, 0, 100 );
MEMSET( scoreConverted, 0, 10 );
before inserting values on these arrays, and inside the block below I added:
DBGPRINTF("Score: %d",score_value);
Having:
...
if ((checkup = IDBRECORD_GetFieldWord (pIDBRecord, &score_value)) == TRUE)
{
DBGPRINTF("Score: %d",score_value);
FLOATTOWSTR(score_value, scoreConverted, sizeof(scoreConverted));
WSTRCAT(scoreCompleto, scoreConverted); }

...
So while it gets the values of the score and puts it on the other array it prints on debug each score value, having:
Score: 29
Score: 26
Score: 25
Score: 24
Score: 23
Which is right.
After the loop is finished I make it display what is inside the array, and I get:
scoreCompleto[0]: 32
scoreCompleto[1]: 32
scoreCompleto[2]: 32
scoreCompleto[3]: 32
scoreCompleto[4]: 32
scoreCompleto[5]: 32
scoreCompleto[6]: 32
scoreCompleto[7]: 32
scoreCompleto[8]: 32
scoreCompleto[9]: 32
scoreCompleto[10]: 32
scoreCompleto[11]: 32
scoreCompleto[12]: 32
scoreCompleto[13]: 32
scoreCompleto[14]: 32
scoreCompleto[15]: 32
scoreCompleto[16]: 32
scoreCompleto[17]: 32
scoreCompleto[18]: 32
scoreCompleto[19]: 32
scoreCompleto[20]: 32
scoreCompleto[21]: 32
scoreCompleto[22]: 32
scoreCompleto[23]: 32
scoreCompleto[24]: 32
scoreCompleto[25]: 32
scoreCompleto[26]: 32
scoreCompleto[27]: 32
scoreCompleto[28]: 32
scoreCompleto[29]: 32
scoreCompleto[30]: 32
scoreCompleto[31]: 32
scoreCompleto[32]: 32
scoreCompleto[33]: 32
scoreCompleto[34]: 32
scoreCompleto[35]: 32
scoreCompleto[36]: 32
scoreCompleto[37]: 32
scoreCompleto[38]: 32
scoreCompleto[39]: 32
scoreCompleto[40]: 32
scoreCompleto[41]: 32
scoreCompleto[42]: 32
scoreCompleto[43]: 32
scoreCompleto[44]: 32
scoreCompleto[45]: 0
scoreCompleto[46]: 0
scoreCompleto[47]: 0
scoreCompleto[48]: 0
scoreCompleto[49]: 0
scoreCompleto[50]: 0
scoreCompleto[51]: 0
scoreCompleto[52]: 0
scoreCompleto[53]: 0
scoreCompleto[54]: 0
scoreCompleto[55]: 0
scoreCompleto[56]: 0
scoreCompleto[57]: 0
scoreCompleto[58]: 0
scoreCompleto[59]: 0
scoreCompleto[60]: 0
scoreCompleto[61]: 0
scoreCompleto[62]: 0
scoreCompleto[63]: 0
scoreCompleto[64]: 0
scoreCompleto[65]: 0
scoreCompleto[66]: 0
scoreCompleto[67]: 0
scoreCompleto[68]: 0
scoreCompleto[69]: 0
scoreCompleto[70]: 0
scoreCompleto[71]: 0
scoreCompleto[72]: 0
scoreCompleto[73]: 0
scoreCompleto[74]: 0
scoreCompleto[75]: 0
scoreCompleto[76]: 0
scoreCompleto[77]: 0
scoreCompleto[78]: 0
scoreCompleto[79]: 0
scoreCompleto[80]: 0
scoreCompleto[81]: 0
scoreCompleto[82]: 0
scoreCompleto[83]: 0
scoreCompleto[84]: 0
scoreCompleto[85]: 0
scoreCompleto[86]: 0
scoreCompleto[87]: 0
scoreCompleto[88]: 0
scoreCompleto[89]: 0
scoreCompleto[90]: 0
scoreCompleto[91]: 0
scoreCompleto[92]: 0
scoreCompleto[93]: 0
scoreCompleto[94]: 0
scoreCompleto[95]: 0
scoreCompleto[96]: 0
scoreCompleto[97]: 0
scoreCompleto[98]: 0
scoreCompleto[99]: 0
but nothing is displayed on the IStatic when I display it.
Any help ?

Hi
Try this increase the array size :
AECHAR scoreConverted[16];
Since score_value is defined as uint16 u need that much space for the conversion of float to WSTR

Hi
Try this increase the array size :
AECHAR scoreConverted[16];
Since score_value is defined as uint16 u need that much space for the conversion of float to WSTR