I have built a user interface for a project im working on. The data entered by the user on the interface is saved in a text file upon closing of the program. This is currently working fine but when I create an executable of my code, data is not written to the txt file upon closing. Is there some special way to build these types of VIs,
The code for writing to the file is in a sub VI and i use the "Write to spreadsheet file" function, i pass in the reference of "C:\Documents and Settings\asha264\Desktop\Single Line\Single Line (9.0)\Data.txt".
Solved! Go to Solution.
Can you show us your code? How are you closing the exe? Could the write "case" not be executed when you close? Since you are using a hardcoded file path name the normal issue of determing a relative pathname, where an exe acts differently than code in development mode, shouldn't be the problem
Its a little hard to show you my code as it consists of a lot of files. I use a button called "Exit Program". I have wired the writing of the file to this button in a case structure.
When I close the program in .vi format this button seems to work fine and the data is written to file. But when I build it into an executable file the button closes the program but does
not write to the file correctly. So im thinking the problem lies in the way i have built it. Could that be the problem?
Are you sure it is not writing the file? Mayb it is writing but not in the location you are expecting. Are you using absolute paths? If not then what method are you using to create the path?
Edit: I just realized that you said in your original post that you are giving the absolute path My bad.
Make sure that your means for signalling the other vi's to exit doesn't have an inadvertent race condition. Remember that LabVIEW is data flow language, that to make sure that certain events occur in a certain order that there is a signal dependecy to force the order of execution. I got bit by that recently when we used a functional global to signal all of the various programmatic loops in the various vi's when it was time to shut down. There was at least one place where, under certain conditions, the loop stop terminal was getting the signal before the "stuff" in the loop had executed. Putting an error in/out on the FG, then puting it in the error line after the functions (actually file writing) guaranteed that the file writes would occur before the "exit" condition was evaluated.