Manejo de C Strings en LabView
Publicado por cx1 (1 intervención) el 30/01/2006 20:45:38
Hola, mi problema es el siguiente, tengo una libreria .so, el cual quiero usar con LabView 7, en esa libreria hay una funcion que me devuelve un "char *parametro" pero en LabView no hay ningun control o funcion que convierta de CStr a LStrHandle, encontre por ahi un CIN que convierte un LStrHande a CStr pero lo devuelve otra vez como LStrHandle, lo intente modificar pero el LabView se cae mi codigo es el siguiente:
/*
* CIN source file
*/
#include "extcode.h"
/* stubs for advanced CIN functions */
UseDefaultCINInit
UseDefaultCINDispose
UseDefaultCINAbort
UseDefaultCINLoad
UseDefaultCINUnload
UseDefaultCINSave
CIN MgErr CINRun(CStr str_orig, LStrHandle str_mod);
CIN MgErr CINRun(CStr str_orig, LStrHandle str_mod)
{
int32 len;
MgErr err = bogusError; /* bogusError is miscellaneous */
/* error code defined in extcode.h */
len = StrLen(str_orig);
/* resize modified LV string to accomodate c string */
if (err = NumericArrayResize(uB, 1L,(UHandle *)&str_mod, len))
goto out;
/* update the length of the modified LV string */
LStrLen(*str_mod) = len;
/* move len bytes from cstring to modified LV string */
MoveBlock(&str_orig, LStrBuf(*str_mod), len);
return noErr;
out:
return err;
}
Alguien podria decirme donde esta el error, o si existe alguna otra forma de mostrar una C String en un indicador de String de LabView?
PD: tambien intente pasar directamente la C string de retorno de la libreria a un indicador de cadena de Labview, no marco error, pero no me marca la cadena como deberia, sino que pone basura ....
/*
* CIN source file
*/
#include "extcode.h"
/* stubs for advanced CIN functions */
UseDefaultCINInit
UseDefaultCINDispose
UseDefaultCINAbort
UseDefaultCINLoad
UseDefaultCINUnload
UseDefaultCINSave
CIN MgErr CINRun(CStr str_orig, LStrHandle str_mod);
CIN MgErr CINRun(CStr str_orig, LStrHandle str_mod)
{
int32 len;
MgErr err = bogusError; /* bogusError is miscellaneous */
/* error code defined in extcode.h */
len = StrLen(str_orig);
/* resize modified LV string to accomodate c string */
if (err = NumericArrayResize(uB, 1L,(UHandle *)&str_mod, len))
goto out;
/* update the length of the modified LV string */
LStrLen(*str_mod) = len;
/* move len bytes from cstring to modified LV string */
MoveBlock(&str_orig, LStrBuf(*str_mod), len);
return noErr;
out:
return err;
}
Alguien podria decirme donde esta el error, o si existe alguna otra forma de mostrar una C String en un indicador de String de LabView?
PD: tambien intente pasar directamente la C string de retorno de la libreria a un indicador de cadena de Labview, no marco error, pero no me marca la cadena como deberia, sino que pone basura ....
Valora esta pregunta


0