LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing OPC URL link as String

Hello

 

I am having trouble with reading OPC URL link in correct format form the System.ini file. (LabView 8.2)

I am able to read the OPC URL link from System.ini file and save it as a string, but in the OPC URL link it contain some back slash and that is where the problem start.

 

I have old EXE  file created in LabView, which read the same OPC URL and able to communicate. I cannot provide this EXE file because it is very big.

 

Please take a look the System.ini file where OPC URL link are stored, and the OPC test.vi.

 

I try to add some extra back slash to take care of escape sequence, but I could not communicate with OPC server.

 

Please help me

 

Thank you,
Download All
0 Kudos
Message 1 of 8
(3,504 Views)
Hi amitt...,

how old is your exe-file? Does it use the configfile-functions or does it aplly it's own string parsing routines?

The configfile-functions apply Windows-conform string formatting, as you already noticed. '\' (backslash) is used to include 'non-printable' characters and so on... You can check this in your indicator 'array' (displaying the results of reading in  the keys as strings). When you switch the display mode to '\ codes' you see that the '\ri'-sequences in your URLs are replaced by '\00' due to string formatting.
'Array 3' and 'Array 4' display the results after reading in as path and show the same results (it's just converted from path to string anyway). Here the same problem applies: the URL are reformatted like '//' to '\' and so on.

Now to the point: I'm sure your old program uses it's own string formatting to avoid those problems. (Maybe it's just older than the first LabView-version including configfile-functions.) You will have to make your own parsing routines using plain 'Read text file' functions!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(3,499 Views)

Amitt:

Are the OPC url contained in the System.ini file the correct ones that you need for your application? Let me know

Rudi N.

0 Kudos
Message 3 of 8
(3,485 Views)
I think I found where your problem is occurring.
I opened up the Read Key.vi.  Inside of that is a Parsed Stored String.VI
I was able to open that up and saw it had special code for handling backslashes.
(I guess someone figured there was a need to store non-printable characters in config files by saving them as backslash codes. I think this probably hurts more people than it would help.)
 
Perhaps you could make copies of these VI's and rename them.  Then edit the new version "Parsed Stored String.VI" and eliminate the special treatement of backslash characters.  It is a confusing little VI, so this task may not be easy.
 

Message Edited by Ravens Fan on 02-14-2007 10:13 PM

Message 4 of 8
(3,479 Views)


@Ravens Fan wrote:
I think I found where your problem is occurring.
I opened up the Read Key.vi.  Inside of that is a Parsed Stored String.VI
I was able to open that up and saw it had special code for handling backslashes.
(I guess someone figured there was a need to store non-printable characters in config files by saving them as backslash codes. I think this probably hurts more people than it would help.)
 
Perhaps you could make copies of these VI's and rename them.  Then edit the new version "Parsed Stored String.VI" and eliminate the special treatement of backslash characters.  It is a confusing little VI, so this task may not be easy.
 

Message Edited by Ravens Fan on 02-14-2007 10:13 PM


What is wrong about the "read raw string (F)" boolean input that skips this entire VI?

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 5 of 8
(3,472 Views)
Hi Rolf,

nice point 😉 I didn't notice this input before, but had to handle special characters in config files as well...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(3,468 Views)
I must admit I didn't notice this input either.  It doesn't show up on the other instance of this VI, I guess because the VI is actually polymorphic and the other instance is for a read path, and thus that flag means nothing to it.
 
Can I recommend that you add the browse button to your control where you select the location of the system.ini file?  I found I had to go into the properties of this control to add it so I could browse to the downloaded .ini file.
Message 7 of 8
(3,462 Views)

Hello Guys

Thank to Rolf, Ravens and GerdW
As Rolf point out that read raw string flag on the Read key.vi takes care of  all escape sequence problem. Also do the same thing when you use the Write Key.vi. So if the Value type is String then this flag comes up, but if not careful we can easily miss that.

 

Here is the some more info.

 

read raw string? Specifies whether the string was written without escaping unprintable and backslash (\) characters. If FALSE (default), the VI replaces any unprintable characters in the string, such as <ESC>, with a backslash and two Hex characters (\xx). If TRUE, the VI does not convert the unprintable characters in the string.

 

 

write raw string? specifies whether to write the string without escaping unprintable and backslash (\) characters. If FALSE (default), the VI converts any backslashes (\) to double backslashes (\\) and replaces any remaining unprintable characters in the string, such as <ESC>, with a backslash and two Hex characters (\xx). If TRUE, the VI does not convert the unprintable characters in the string.

 

I think this is very important point to keep in mind.

 

Thank you

 

0 Kudos
Message 8 of 8
(3,442 Views)