LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write Key (Path)

Solved!
Go to solution

I'm trying to develop some VIs that work with Configuration (.ini) files in a Windows environment.  My problem is that writing a Windows file path (in the form C:\Folder\File.dat) results in an entry in the form /C/Folder/File.dat.  Turns out there's an internal routine Specific Path to Common Path that translates Windows file paths into this "forward-slash" version.  I'm starting with a Configuration file whose paths are in "Windows" format, and want to create an output file also in "Windows" (not Common) format.  [Turns out that reading a Key (Path) has a Common Path to Specific Path VI to "reformat" it, but if the format is already Specific, or Windows, path, it will "pass through" unchanged, as it should].

 

One solution, of course, is to recode the NI VI's myself, but that seems a bit excessive.  Anyone have any suggestions?  [Ooh, I didn't think about OpenG ...]

 

BS

0 Kudos
Message 1 of 5
(2,925 Views)

Nope, OpenG has a set of Configuration I/O routines that take a variant type, but if the input is a Path, they simply use the NI Write Key (Path) VI, doing the Specific to Common conversion.  Ah, I think I just figured it out -- convert the Path to a String, and then pass it to the routine.  As it's late, and I'm tired, I'll check this tomorrow, and mark it as a "Solution" if I'm right ...

 

BS

0 Kudos
Message 2 of 5
(2,922 Views)

So I lied -- decided not to wait, try the simple fix.  Almost!  If I have a path C:\Folder\File.dat and write it as a Path, I get /C/Folder/File.dat.  If I covert it to a String and write it (as a String), I get C:\\Folder\\File.dat (note the doubled back-slashes).  Clever, but not clever enough ...  Now I'll quit for the night ...

0 Kudos
Message 3 of 5
(2,920 Views)
Solution
Accepted by topic author Bob_Schor

There is an input to the Write Key (String) VI that is "write raw string?". If you set this to TRUE, it will write the string without the double-backslashes. Similarly, you'd need to wire a TRUE to the "read raw string?" parameter on the Read Key (String) VI.

Message 4 of 5
(2,909 Views)

And (not surprisingly) Darren finds the missing piece!  Thanks, this additional input plus my path-to-string conversion does the (functional) trick of "removing" the Specific to Common conversion of the Path format.

 

Incidently, I first tried (this morning, when I'm more awake) simply writing my own Write Key (Specific Path) VI in my own Project.  However, Write Key exists "inside" a library in VI.Lib, with Private functions, so I'd either have to put my own (non-NI) function inside VI.Lib (which I'm loathe to do) or duplicate multiple VI.lib functions inside my Project.

 

 

0 Kudos
Message 5 of 5
(2,886 Views)