View Full Version : string data from an Xpanel form

02-07-2005, 11:26 PM
I have an Xpanel form with various data fields. I can get the int and float data from the form using formget().

one of my field is a string, whenever I try to get this data i get nothing returned.

anyone know what needs to be done.

here is a code snippet:
int skipn =1;
char * baseName = "blabla";


(*lwxpf->post) ( panID );

skipn = (*lwxpf->formGet)(panID,SKIP);//this works fine
baseName = (*lwxpf->formGet)(panID,F_NAME);//this returns nothing


02-10-2005, 09:54 AM
Eh...actually the "skipn" one should not work, or rather, produce unpredicatble results. When are you trying to read the returned string? After you destroyed the panel? I assume the pointers returned by formGet become invalid once you destroyed the panel (but the SDK doesn't give precise information about that...)

I think it should be more like:

int skipn =1, ok, *ival;
char * baseName = "blabla", *newName, *sval;


ok = lwxpf->post( panID );

if(ok) //the user pressed "ok" and not "cancel"
ival = lwxpf->formGet(panID,SKIP);
skipn = *ival;
sval = lwxpf->formGet(panID,F_NAME);
newName = strdup(sval); //needs #include <string.h>

Don't forget to free the memory of the string if you don't need it anymore.
(not that i never explicitly dereference a function pointer, it just confuses me, wouldn't work in C++ and is of course totally unnecessary :) )

02-10-2005, 06:41 PM
Thanks that worked