08-08-2023 12:22 PM
Hello guys,
I really need your help.
I need to read an .icd file and at line 56:
CameraAttributes::deviceSensorControl::ExposureTime = "2e+04"
I just want to replace "2e+04" with "400".
I've tried but my vi below deletes all the lines.
How to do please please?
Thanks
Solved! Go to Solution.
08-08-2023 01:00 PM
There's a lot of issues with your code but the main one is that you're using "Replace substring" completely wrong. It has two outputs and you're using the wrong one, but even if you were using the right one you also don't put in anything for the Offset and Length values, which you also need to do what you're trying to do.
Your ICD appears to be in the standard "Configuration File" format, even though it's .icd instead of .ini. You could try using those VIs.
https://www.ni.com/docs/en-US/bundle/labview/page/configuration-files.html
The other option would be to use the "Search and replace string" node instead of "Replace substring", but I strongly recommend the configuration file VIs instead.
08-08-2023 03:12 PM
I completely agree with @Kyle97330. I tried running your code, and had some problems getting the String read (having to do with the relative location of my sub-VI and the location of the String). Once I had that fixed, "Scan from String" blew up on me because you had the wrong Format string (you ignored the double-quotes). Finally, Replace Substring is also (probably) going to fail as you might not have counted the number of characters to insert correctly.
Whereas if you process it as a Configuration File, all you have to do is to identify (I don't remember the names used there, but could easily look them up, a better exercise for you to do that) and then just replace the "value".
Bob Schor
08-10-2023 03:22 AM - edited 08-10-2023 03:28 AM
08-10-2023 02:13 PM - edited 08-10-2023 02:22 PM
Here's all you probably need.
(Of course you want to add some trimmings (error handling, etc.)
Also note that I disabled EOL conversion.
08-10-2023 02:41 PM
Hi @alexderjuengere,@altenbach,
Thanks you very much for your reply and take your time to help me.
@altenbach this is exactly what I want and most most simple.
Thanks you guys 🙂
Good Night
08-10-2023 02:54 PM
No one ever asked the OP why they needed to do this. Reading it as a config file key value would have bypassed all kinds of manipulation if the goal was to get a floating point number.
08-10-2023 03:40 PM
@billko wrote:
No one ever asked the OP why they needed to do this. Reading it as a config file key value would have bypassed all kinds of manipulation if the goal was to get a floating point number.
Note that 2e+04 (i.e. 20000) is not 400, so my suspicion was that it's not really the formatting but the numeric value that's the problem and needs to be changed. (Replacing with 4e+02 would probably have worked too....). 😄
08-10-2023 04:39 PM
@altenbach wrote:
@billko wrote:
No one ever asked the OP why they needed to do this. Reading it as a config file key value would have bypassed all kinds of manipulation if the goal was to get a floating point number.
Note that 2e+04 (i.e. 20000) is not 400, so my suspicion was that it's not really the formatting but the numeric value that's the problem and needs to be changed. (Replacing with 4e+02 would probably have worked too....). 😄
Did I read that backwards??? Yikes.
08-11-2023 01:54 AM
@altenbach wrote:
Here's all you probably need.
(Of course you want to add some trimmings (error handling, etc.)
Also note that I disabled EOL conversion.
in a nutshell 😄
what is also worth mentioning is that "use regular expression" is turned off