Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

I am writing a BREW database program, that can dynamically adjust the number of fields to create, based on a "for" loop.

The issue is, that all pBuffer values (across fields) within a record, become equal. I ran it through debug, and all pBuffer addresses within a record, have the same pointer address!

Is it possible in BREW to use a loop to create database records, or am I missing something? Why isn't a new pBuffer address, created with each loop iteration?

The basic code:

char fieldValue [200] = {" test "};

//Build database record-fields
for (j=0;j<4;j++){
STRCAT(fieldValue, ".");//test data

dbField[j].fName = j;
dbField[j].fType = AEEDB_FT_STRING;
dbField[j].pBuffer = (void *)fieldValue;
dbField[j].wDataLen = STRLEN (fieldValue);

Thanks,
Martin

Got it!!
Sample Code:
int j;
char temp_val[4][30] = {'\0'};
char test_data[30] = {"a"};
//Build database record-fields
for (j=0;j<4;j++){
STRCPY(&temp_val[j-1][30],STRCAT(test_data,test_data));
dbField[j].fName = j;
dbField[j].fType = AEEDB_FT_STRING;
dbField[j].pBuffer = (void *)&temp_val[j-1][30];
dbField[j].wDataLen = STRLEN (&temp_val[j-1][30]);

Needed a 2-D array, to store each field's temp pBuffer value.
Martin

Got it!!
Sample Code:
int j;
char temp_val[4][30] = {'\0'};
char test_data[30] = {"a"};
//Build database record-fields
for (j=0;j<4;j++){
STRCPY(&temp_val[j-1][30],STRCAT(test_data,test_data));
dbField[j].fName = j;
dbField[j].fType = AEEDB_FT_STRING;
dbField[j].pBuffer = (void *)&temp_val[j-1][30];
dbField[j].wDataLen = STRLEN (&temp_val[j-1][30]);

Needed a 2-D array, to store each field's temp pBuffer value.
Martin

Good Day!
I am a new BREW Developer and it is really a new world for me though I know that it is a C/C++ programming base. But I really need a sample tested and running program even it is a basic program including how to run/compile and everything.
I already have a BREW Application in my computer including its SDKs.
How I wish you could give me some help. Thank you in adavance and I'm looking forward to hear from you in due course.
Pas

Good Day!
I am a new BREW Developer and it is really a new world for me though I know that it is a C/C++ programming base. But I really need a sample tested and running program even it is a basic program including how to run/compile and everything.
I already have a BREW Application in my computer including its SDKs.
How I wish you could give me some help. Thank you in adavance and I'm looking forward to hear from you in due course.
Pas

look in the examples directory of the brew installation.

look in the examples directory of the brew installation.