LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save variable value and locking the code

Hello MilkyStone,

you have to change filepath when you build an app. There are many other threads on this topic!

Essentially, when building an app the path to a vi contains one more folder: from c:\my_prog.vi to c:\my_prog.exe\my_prog.vi. This has to be taken into account when building path by using 'path to current vi'! Simply test for LabView environment (there is a vi property to do so) and strip one more folder, when executable...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 21 of 24
(1,283 Views)
Dear GerdW, Morning!
 
Thanks for your suggestions.
 
I change the path of .ini file in your VI, and it works well.
 
I really appreciate it~!
0 Kudos
Message 22 of 24
(1,274 Views)
Hi! I'll go ahead and answer for Philip. This VI automatically creates an .ini file for the VI it is saving the control and indicator values for. For instance, if your VI is called C:\My Documents\myVI.vi, then it will create an .ini file called C:\My Documents\myVI.ini.

The problem is that when you build an executable, your VI is now located at C:\My Documents\myApp.exe\myVI.vi. This means that this application is trying to save the .ini file inside the .exe file at C:\My Documents\myApp.exe\myVI.ini, which is causing the error I believe. Instead, you will need to strip the paths twice for built executables, so that you save it in My Documents (or wherever of course). This is common practice with building executables. See here or here for more information. Hope this helps!
Jarrod S.
National Instruments
0 Kudos
Message 23 of 24
(1,261 Views)
Ah, I see now someone had already posted. I should have checked the next page before responding! Alas...
Jarrod S.
National Instruments
0 Kudos
Message 24 of 24
(1,259 Views)