LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

add text file to my project

Solved!
Go to solution

Hi,

 

I'd like to create a Log file. I know how to do it by including the path of the log file "c:/......" it works on my pc. However, my programm will run on a machine which has no C directory. I could make it work by putting it on a usb key and plug the key on the machine but that's not the idea.

So i would like to know how to add the file in project (or in dependencies maybe) to make the screen work. Actually i get the error "LabVIEW:  The path is empty or relative. You must use an absolute path."

 

Thanks in advance

0 Kudos
Message 1 of 11
(5,175 Views)

Hi ghamm,

 

you could open a dialog to let the user choose a path.

Or you could read a known folder path using the GetSystemDirectory function (like "user documents" or "public documents")!

 

Just using a filename without any file path will never work…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(5,165 Views)
Solution
Accepted by ghamm03

Good suggestions from Gerd. The File Dialog express VI is surprisingly useful if you want to pop up a dialog.

Another approach is to use the "Application Directory" function, which returns a path to where your project is stored (where your executable is stored in a built exe). You can then build a path using that.

Ian
LabVIEW since 2012
0 Kudos
Message 3 of 11
(5,161 Views)

Thanks for your answer,

I can't use the dialog box, my programm open it at each loop of my for.

I open the file in my controller.vi to add logs then i close the file and i reopen it in my View.vi to display what has been saved.

I'll try the second option on the machine as soon as possible

 

0 Kudos
Message 4 of 11
(5,142 Views)

Hi ghamm,

 

I can't use the dialog box, my programm open it at each loop of my for.

Nobody said you should ask for a folder inside a loop!

Usually you only ask once before the loop. And even better: usually you also store settings in additional files so the user does not have to choose the very same folder with each start of your VI…

 

I open the file in my controller.vi to add logs then i close the file and i reopen it in my View.vi to display what has been saved.

So you write to the log file in one place of your program and you read from the very same file in a different location in your program? Does this sound like a "good" option?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 11
(5,136 Views)

You're telling me to store settings in additionnal files when i said that i couldn't use files because i can't find them from the machine..

 

And how it should work ? One vi to display all the logs from the launch of the machine, 1 vi to add the newest actions.

0 Kudos
Message 6 of 11
(5,101 Views)

Hi ghamm,

 

You're telling me to store settings in additionnal files when i said that i couldn't use files because i can't find them from the machine..

Why can't you use files?

In your first post you said you want to create file so I guess you CAN use files!?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 11
(5,099 Views)

I can create and use file only if they are link to the project, i can't have a path like "C:...." The machine is really basic, it can't get something on the server

0 Kudos
Message 8 of 11
(5,091 Views)

Application Directory is not in my function list

0 Kudos
Message 9 of 11
(5,090 Views)

Hi ghamm,

 

Application Directory is not in my function list

Check the file path constants

 

i can't have a path like "C:...." The machine is really basic, it can't get something on the server

Does your "machine" have any local storage?

Then you can/should use it - all you need is to determine the correct path!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 11
(5,087 Views)