LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FStringToPath crash in CIN

Im getting a crash when including this in my CIN... new to this game... any idea? Thanks! -THomas

//===============================================

char pfilename[200];
File fileDescriptor = NULL;
Path pathToCreate = NULL;
LStrHandle myStrHandle;


sprintf(pfilename,"output.txt");
myStrHandle = (LStrHandle)(&pfilename);
FStringToPath(myStrHandle, &pathToCreate));

//================================================

Message Edited by surferinsd on 05-19-2005 01:02 AM

0 Kudos
Message 1 of 4
(2,371 Views)
Hi Thomas,

Do you get an error message when the crash occurs?

Also, have you checked out our Using External Code in LabVIEW document located here:

http://digital.ni.com/manuals.nsf/websearch/8D930295FFBF9F7686256D2C00624728

It has useful information about how to use the CIN.

Thanks,
Laura
0 Kudos
Message 2 of 4
(2,355 Views)
The error message is "Labview has encountered an inconvenience and needs to close".

I've had my eyes in the manual for several days now. My problem is the lack of bridges from ordinary C types to the LabView types. Sometimes I can't even find what the types are made of (eg, uChar or UPrt), and sometimes I can't write into LabView Structures because typically they are:
typedef LVlist{
int32 length;
basic_type content[1];
}
and I cannot assign a pointer to "content" because the compiler tells me "cannot assign array".

I work in XP home with LabWindows.
I do heavy signal computations in C and am trying to write the result in a file, the file name depends on time so I compute it in a C string. But the ordinary C file writing functions stop working when I turn my program into a CIN (they do as executable, but fopen() returns NULL in a CIN). That's why I am calling LabView functions as the back end.

I also tried the following:

CToPStr(pfilename,pformatted);
pathToCreate = FMakePath(NULL, fRelPath, pformatted, NULL);
myUptr = (UPtr) malloc(200);
printf("%d\n", FFlattenPath(pathToCreate, myUptr));
printf("%s\n", myUptr);
if (err = FCreate(&fileDescriptor, pathToCreate, PERMISSIONS, openReadWrite, denyNeither, NULL))
goto out;

besides the fact that Im not sure what UPtr is, I should print what was in pfilename.
But instead I get a wrong length for the flattened path, a meaningless string for the content,
and the FCreate creates a LabView error of execution inside the CIN (but does not crash LabView as the other error did).


So either way, I need a way to create a file whose name I have in a C string... can you help?
0 Kudos
Message 3 of 4
(2,353 Views)
Why are you using the CIN? It may be much easier for you to make a dll since you seem to already have CVI code written. Then you can call that dll in LabVIEW using the call library function node. FAQ: Using dlls with LabWindows/CVI
0 Kudos
Message 4 of 4
(2,332 Views)