08-19-2010 10:54 AM
Hi,
I am new to LabWindows and I am trying to save some test data into a file where my project directory is located. I was able save the test data from the main cvicallback function into result.txt but not the test data from another cvicallback function that was called by the main cvicallback function into result.txt. Can someone point out what I am doing wrong here? Here's what I have in the main cvi call back function.
GetProjectDir (pathname);
MakePathname (pathname, "result.txt", pathname);
fid = fopen (pathname, "a+");
status =fprintf (fid, "Test data or message from Main CVICallback");
fclose (fid);
And here's what I have in the other cvicallback that was called by the main cvicallbak function.
fid = fopen (pathname, "a+");
status = fprintf (fid. "Test data or message from Another CVICallback");
Thanks,
Yuna
Solved! Go to Solution.
08-19-2010 11:29 AM - edited 08-19-2010 11:30 AM
Yuna:
Are you getting any error messages?
How is the second function get called? Are you sure it is being called? You can set a breakpoint on one of its lines of code to make sure.
You need to post more code for us to get the bigger picture.
Is pathname a global or is it local to your main?
If pathname is local, how does it get passed to the second function?
Do you close the file in your second function?
I'm guessing it's just a typo, but the fprintf in the second function shows a period after fid, and it should be a comma. You're better off pasting code into your message instead of retyping it.
08-19-2010 11:55 AM
AI S:
Thank you for raising these questions. It turns out that the pathname was local so it wasn't getting passed to the second funtion. Once I made pathname global, I was able to get my test message from the second function.
Thanks,
Yuna