キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Scam string and replace value

Dear all,

 

I have one string that is read from Excel like this: "-90 db, 10 us, 100 Hz" that is used in some tests. I can't change this format.

The numbers can change and the code should be generic for any number.

For an expecific case I would like to replace the second number (duration in us) for a decimal that I will calculate.

This means that I only have to find the second "%d" (decimal number in the string) and replace for another number.

Is there any VI for that? I have been trying with some of them inside loops with no sucess... Please I would like some tips.

 

Thank you,

Thais Marques

0 件の賞賛
メッセージ1/15
3,895件の閲覧回数

One of the many possible ways:

test.png

Hope this helps.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 件の賞賛
メッセージ2/15
3,877件の閲覧回数

Hi Thais

 

You can do something like this

 

1) Split string up in 3 bits by using the ,

2) Pull out what is between the 0 spaces og the middle string

3) Change this to a floating points tring with X number of precision

4) Build the string back up.

 

I have also attached the example in LabVIEW 2012 format.

SplitString.PNG

 

Best Regards

Anders Rohde

Applications Engineer

National Instruments Denmark

0 件の賞賛
メッセージ3/15
3,872件の閲覧回数

Ugh, a pet peeve of mine.  You capitalize the "H" in "Hz" - why not the "B" in "dB?"  After all, they both refer to proper names.  😉

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 件の賞賛
メッセージ4/15
3,867件の閲覧回数

@billko wrote:

Ugh, a pet peeve of mine.  You capitalize the "H" in "Hz" - why not the "B" in "dB?"  After all, they both refer to proper names.  😉


Unit capitalization is one of my peeves as well.  There's nothing quite like reading a test procedure and it says "Pulse the input for 500MS".  500 Megaseconds!????  Oh, you mean 500 milliseconds.  That's 500ms (or if you really want to capiltalize the seconds, 500mS).



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 件の賞賛
メッセージ5/15
3,857件の閲覧回数

dear gosh people.
i just typed myself this. that is a simplification of my string (because the whole problem is much bigger!);

What is the problem of one letter not capitalized?!!!!!!!!!!!!!!!!!!!! that is not the point of my question.

that is not a document, is not a report............ just a post!!


anyway thanks for who helped me really 🙂

0 件の賞賛
メッセージ6/15
3,850件の閲覧回数

 

Use the 'Spreadsheet String To Array' then 'Fract/Exp String To Number' to give you an array of floats from the Excel spread sheet.

You can then pick and choose which item you need or skip over or replace.

 

Scan string and replace value.png

 

I used a float because db and hz could be given as floating point

Omar
0 件の賞賛
メッセージ7/15
3,828件の閲覧回数

Hi Omar,

 

is there a reason to use two functions when one will do the same?

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 件の賞賛
メッセージ8/15
3,823件の閲覧回数

is there a reason to use two functions when one will do the same?

 

No. I first though the OP needed to replace a string keeping the output a string, So I started down that path keeping eveything as strings.

 

Then noticed their use of  ["%d" (decimal number in the string)] in their original post and at the last just added the extra convertions.

 

If all they wished to do is change the 10 us then the search and replace with regular expersion turned on will work.

Search and replace.png

 

Omar
0 件の賞賛
メッセージ9/15
3,812件の閲覧回数

I just realized that is possible that not necessary the string that is been read will be given in "us" because allows that you type in "ms" also.

So here goes my not-so simple solution: (with B capitalized :P)

 

noise.png

0 件の賞賛
メッセージ10/15
3,795件の閲覧回数