05-01-2015 04:30 PM
I have a program where users can write RPN equations into txt files so that the number and type of equations are completely customizable at run time. I need to be able to iterate through .txt files in an Equations folder to load the equations into memory. How can I do this in real time?
I know I could make the files eq 1.txt through eq 2.txt and iterate through until one doesn't exist, but my standard method has been to name the filename the same as the equation name. Either way works.
Thank you.
05-03-2015 11:32 PM
First idea: Use the Windows API functions FindFirstFile()/ FindNextFile(). More info on MSDN.
05-04-2015 08:13 AM
Hi Michael,
You could also use the GetFirstFile and GetNextFile functions that come built into CVI. These functions should allow you to iterate through the files in a directory.
GetFirstFile: http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/libref/cvigetfirstfile/
GetNextFile: http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/libref/cvigetnextfile/
Hope this helps,
Kevin
05-04-2015 08:14 AM - edited 05-04-2015 08:15 AM
FindFirst isn't supported in the RTOS.
I just tried GetFirst and it pops up.
Thanks!
05-04-2015 02:29 PM
GetFirst File is not supported in CVI Real Time.
05-05-2015 05:25 PM
Looking through the RT Utility Library I don't see any corresponding functions for GetFirstFile, you may be limited to just naming the files as you mentioned in your original post. Sorry.
-Kevin
05-06-2015 08:20 AM
That is what I did. I name the files Equation 0.txt through Equation n-1.txt and use GetFileInfo to check if they exist. I put the equation name at the top of the text file whereas I used to get it from the file name.
05-07-2015 03:47 AM
The RT OS is Posix-based, right ? (I may be wrong, I tested it years ago). If so, does it provide you with standard POSIX library ? In that case you may want to use dnotify() to know when files are added/removed from the directory you are monitoring.
<P>
Another solution would be to have a list file that lists all the files that sould be used. This way you iterate quicker and you can also enable/diable files quickly instead of having to rewrite/delete/move them.