LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How replace in line 56 to replace "2e+04" with "400"

Solved!
Go to solution

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

0 Kudos
Message 1 of 10
(1,363 Views)

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.

Message 2 of 10
(1,347 Views)

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

Message 3 of 10
(1,319 Views)
Solution
Accepted by Steph_2

the following snippet shows rather brute-force approach, but will probably work on the .icd file, which are typically generated via NI MAX in C:\Users\<user_name>\Documents\LabVIEW Data

 

Spoiler
400.png

 

Message 4 of 10
(1,260 Views)
Solution
Accepted by Steph_2

Here's all you probably need.

 

altenbach_0-1691694751360.png

 

(Of course you want to add some trimmings (error handling, etc.)

 

Also note that I disabled EOL conversion.

Message 5 of 10
(1,228 Views)

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 

 

 

 

 

0 Kudos
Message 6 of 10
(1,215 Views)

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 10
(1,207 Views)

@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....). 😄

0 Kudos
Message 8 of 10
(1,191 Views)

@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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 9 of 10
(1,181 Views)

@altenbach wrote:

Here's all you probably need.

 

altenbach_0-1691694751360.png

 

(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

alexderjuengere_0-1691736804021.png

 

0 Kudos
Message 10 of 10
(1,156 Views)