08-18-2010 02:55 AM
The values inside string1 is like this:
string 1 = 0x00455CEO "C:\\Users\\Student\\Desktop\\SimpleSquare.txt".
I will try to exp,ain it a bit more. I am having two callback functions for 2 different control buttons. when one of them (Func1) is pressed, it calls another function (test.c). It is in this test.c i need to get value of another control from the uir. For that i used this command in test.c
GetCtrlVal (panelHandle, PANEL_STRING_2,string1); FILE *OutFile = fopen(string1,"w"); // where string1 is a path name ( "C:\\Users\\Student\\Desktop\\SimpleSquare.txt".).
.
..................
fprintf(OutFile,"%12.7f\n",P) ;
After performin this callback function I press the another button in the UIR (Func2).
this is used to view the file which was saved above.
For that i jus obtain the string1 and opens it.
int CVICALLBACK Func2 (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: GetCtrlVal (panelHandle, PANEL_STRING_2,string1); OpenDocumentInDefaultViewer (string1, VAL_NO_ZOOM); } return 0;
So basically when the prgm is run , if u press func2 button first , it opens the previoulsy saved SimpleSquare.txt file. What i need is , I need to press Func1 button, save the new data and file as SimpleSquare.txt and then when i press Func2 the new file should b opened.
08-18-2010 03:35 AM
@Nghtcrwlr wrote:
error:
NON-FATAL RUN-TIME ERROR: "generate.c", line 14, col 21, thread id 0x00000718: Library function error (return value == 0 [0x0]). (EINVAL) Invalid argument
Can you clarify exactly which line the error occurred on? Your previous post implied that it was on the fopen... one, but according to your most recent post it seems likely to be on the OpenDocument... one instead. If this is the case, perhaps all you need to do is have a fclose(OutFile); at some point before you try to re-open the file with OpenDocument...
Some applications insist on having exclusive access to a file and will not allow it to be opened more than once at a time.
JR
08-18-2010 04:33 AM
i alredy have an fclose() command at the end of test.c file.
But now i found something else. I guess it has something to do with getting the path in the test.c.
When i replace the command
FILE *OutFile = fopen(string1,"w");
with
FILE *OutFile2 = fopen("C:\\Users\\Student\\Desktop\\SimpleSquare.txt","w");
the prgm wrks perfectly.
I want the same path that is being used to save data to be used here. Is there any other way to get that value from the control directly.
In the main.c i have used GetCtrlVal to get value and open the file and save. I jus need the same path to be opened in test.c
any idea why?? I have defined the string1 outside the main.c to be used in test.c. But no use.
08-18-2010 05:21 AM
Sorry I should have spotted the error in post number 11. When you define a string to C of the form:
char string1 [512] = "C:\\Users\\Student\\Desktop\\SimpleSquare.txt";
then the actual contents of the string become: "C:\Users\Student\Desktop\SimpleSquare.txt" - note that the C compiler has interpreted each \\ as a single \.
So in your post 11, it is obvious that you have too many '\' characters in the pathname at run time, resulting in the error message from the operating system.
JR
08-18-2010 06:34 AM
Ok.. thats what caused the problem. Now i used a second command with different name for the same string value
GetCtrlVal (panelHandle, PANEL_STRING_2,string2);
GetCtrlVal (panelHandle, PANEL_STRING_2,string1);
and used them in two situations. now it worked. Earlier i was trying to get the value with too many \\ characters. Now its working..
thnx JR