02-19-2021 11:50 PM
I need a small VI with three terminals that stores log-information in a file. Terminals: Error IN/OUT and string input.
However, the VI must have information about where to store the file and the filename. In what way can that be done and still only have three terminals?
WIth my level of experiance I can think of 3-4 ways.
1. Each time this small log-VI are called it reads path info from a INI-file.
2. The VI has a path-const.
3. Global variable
4? The first time VI are called it reads the path from the INI-file. The VI are mem-persistent so it never lose the path information.
I do not know how or if it is possible to have the VI to work like this.
Please advice, thanks.
Solved! Go to Solution.
02-20-2021 01:27 AM - edited 02-20-2021 01:28 AM
I think an "Action Engine" could work for #4.
02-20-2021 07:50 AM
AE is definitely something I will study more. Thanx.
02-20-2021 02:04 PM
Yes, there are plenty of solutions, but you need to make it fail-safe. For example if it reads the path from the ini file and the ini file or path entry does not exists for some reason, it should pop a file dialog on first call, verify the entry to make sure the location is writeable, then create or update the ini file.
If you decide to use a path diagram constant, make sure to make it relative to a defined folder (e.g. "user home" or similar). so it will continue to work, even if run on a machine with a different OS or different file layout.
02-20-2021 11:23 PM
I like the VI that returns "My Documents" path. From that point, I use a relative path or simply save the log-file in My Docs.
I have also a check that the string having only printable chars and length are less then 256.
02-22-2021 08:05 AM
@TakeANap wrote:
I like the VI that returns "My Documents" path. From that point, I use a relative path or simply save the log-file in My Docs.
I tend to save everything in the "Public Documents" folder. That way, any user can access the data.
02-22-2021 12:43 PM
I almost have a event-structure in my applications. Why not place the log-VI in a case that gets activated if a string-ctrl gets updated? I can then have a path as terminal from the "read-INI" file becuse I only need to have one copy of the log-via and that is inside the event-case.
In the application, I use a local-var to write to the string that activates the event.
"Things can be done in hundred ways".