 |
SEAL The SEAL Forums
|
| View previous topic :: View next topic |
| Author |
Message |
Eric T
Joined: 22 Jun 2005 Posts: 8 Location: Selby, North Yorks, UK
|
Posted: Thu Jul 14, 2005 3:35 pm Post subject: Exporting a char string (in C not C++) from SLX |
|
|
Hi folks,
Does anyone know how to get a character string out of an SLX export, please (in C, not C++)? Sorry if it's a naive question -- I'm new to C.
The example for Pi works okay, like this:
pi = (float *) get_symbol(sxl_handle, "_pi");
if (!pi)
{
DebugF( "Pi wasn't found or wasn't exported.", 0);
}
else
{
sprintf(tmp, "Pi = %f", *pi);
DebugF(tmp, 0);
}
But all I can get out of a string is the first char.
Many thanks in advance,
Eric T.
--------------------------------------------
/* From the host application: */
void GetId(h_sxl sxl_handle)
{
char tmp[15];
char result[15];
/* get_symbol() returns the address of the function "hello" */
char (*id)() = get_symbol(sxl_handle, "_hello");
/* id() now calls hello using the address and returns a
pointer to hello's output: "id=such-and-such" */
*result = id();
sprintf(tmp, "Library returned %s.", result);
DebugF(tmp, 0);
/* outputs only "i", not "id=such-and-such" */
}
--------------------------------------------
/* In the SLX application: */
char helo[15];
int main(char *args)
{
EXPORT (hello);
}
char hello()
{
strncpy(helo, "id=dialapp.sla", 15);
return * helo;
}
-------------------------------------------- _________________ http://www.anchor92.freeserve.co.uk |
|
| Back to top |
|
 |
Eric T
Joined: 22 Jun 2005 Posts: 8 Location: Selby, North Yorks, UK
|
Posted: Fri Jul 15, 2005 10:45 am Post subject: SLX - Exporting Char String |
|
|
Hi folks,
I've had another go at exporting a char string from SLX, but with no success. Hopefully the example below will make things clearer:
Any help would be gratefully received.
Many thanks,
Eric T.
--------------------------------------------
/* From the host application: */
void GetId(h_sxl sxl_handle)
{
char tmp[50];
char result[50];
char (*pt2function)() = NULL;
/get_symbol returns the address of the "ReturnID" function */
pt2function = get_symbol(sxl_handle, "_ReturnID");
strncpy(tmp, "\0", 50);
/* ReturnID() returns pointer to "id=such-and-such" */
*result = (*pt2function)();
sprintf(tmp, "Library returned %s.", result);
DebugF(tmp, 0);
}
--------------------------------------------
/* In the SLX application: */
char id[16];
int main(char *args)
{
EXPORT (ReturnID);
}
char * ReturnID()
{
strncpy(id, "id=dialapp.sla", 16);
return id;
}
-------------------------------------------- _________________ http://www.anchor92.freeserve.co.uk |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|