From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to Number conversion

Solved!
Go to solution

Hi Jick,

 

here's a snippet with code that should work on any computer.

 

Formatwithdot.png

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 21 of 46
(1,585 Views)

Hi TCPlomp,

 

I am sure it works but the conversion should be vice versa (from string to number).

 

Jick

0 Kudos
Message 22 of 46
(1,564 Views)

Ton & Gerd,

 

I think you might be wasting your time. Jick is a little too lazy to do this properly. When I pointed out:

 


James W wrote:

Word of warning: 

 

Changing the regional settings works.... until you port the code onto another machine and forget why you have the failure. I suspect many people would agree with me when I suggest you fix the problem properly in the LabVIEW code so you don't see it again rather than risk a headache in 6 months time when you've forgotten why this is happening and your PC has just been replaced!

 

You will probably pay later for your "laziness" now.

 

James


 

His response was:

 


  

Jick

Good point. I added a note into the LV code. Thanks!


 

- Adding a note will note solve the problem, It'll just make it slighty easier to debug when it breaks again - if the note is in the correct place. We've all told Jick what to do, I've even spelled out how to deal with all of the strings so it can be done in a simple VI just before the Text output, but that's too much work.

 

Lets leave this code to break later.

2 solutions have been offered, a correct 1 and a temporary bodge, Jick has chosen the bodge. It's always sad to see only half a job done. Smiley Sad

 

James

 

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 23 of 46
(1,544 Views)

"a temporary bodge" is enough for me at this point. I wouldn't call it laziness. The LV code will be deleted after some units are tested correctly. Sometimes (deadlines) you don't have enough time to spend with the code if there is faster solution available. This time faster solution was OS's settings change. Next time maybe something else.

 

I hope someone gets tips from this discussion.

Next time better luck.

 

Jick

0 Kudos
Message 24 of 46
(1,534 Views)

Hi Jick,

 

what do you need else?

 

Yu have to convert a string into a number in LB, then give it to TS --> See my post no.3 in this thread.

 

In TS, you have to convert the DBL into a string for giving it to the uC --> see post 21

 

 

Regards.

 

Stefan

0 Kudos
Message 25 of 46
(1,507 Views)

Hi SK@NIG,

 

"In TS, you have to convert the DBL into a string for giving it to the uC". In this case, I have a DBL with comma "," in TS (?) and if I send it to the uC it gives me error back.

 

The procedure one more time:
LV: "something...23.11..."-->convert to number--> 23,11-->Send to TS-->23,11 (there might be also some calculations)-->Send to uC-->Error because of comma ","

 

I kind of temporarily solved this problem and it is fine now. But I am curious to test some code in LV (if there really is) which gives me a dot "." to the indicator without changing any settings. Earlier, I was busy to solve this by coding because of deadlines.

 

Thanks for your help anyway!

 

Jick

0 Kudos
Message 26 of 46
(1,493 Views)

Jick wrote:

LV: "something...23.11..."-->convert to number--> 23,11-->Send to TS-->23,11 (there might be also some calculations)-->Send to uC-->Error because of comma ","

Which software package sends the string to the uC? LabVIEW or Teststand (I assume LabVIEW)

But I am curious to test some code in LV (if there really is) which gives me a dot "." to the indicator without changing any settings.



See my reply here with this snippet:

Formatwithdot.png

 Note, this code was run on an OS with a ',' (comma) as decimal sign.

 

The function I use is 'Format into string' with the following format specifier, '%.;%.2f',this specifier consits of two formatting codes:

  • %.;  Tells the format into string function to use a '.' as the decimal sign in the rest of the formatting actions
  • %.2f Tells the format into string function to format a numeric as a floating point string with 2 characters after the decimal sign


You can do really awesome things with the format into string function. You can use the same format strings as display formatters for numeric indicators.

 

Ton

Message Edited by TCPlomp on 28-04-2010 09:23 AM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 27 of 46
(1,486 Views)

But your VI converts from number to string and I am interested in conversion from string (which includes ",") to number (which includes ".")...

 

Jick

0 Kudos
Message 28 of 46
(1,479 Views)

Hi Jick,

 

did you read this:

"You can use the same format strings as display formatters for numeric indicators."

 

Just open the properties, select "Advanced" for formatting... That's the way in LabVIEW.

 

When TestStand behaves different, you should ask this in a TestStand forum as well...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 29 of 46
(1,474 Views)

Hi GerdW,

 

Yes, I red it and it is good. But it is not possible to programmatically temporarily "force" LV to change the decimal separator from , to . ?

0 Kudos
Message 30 of 46
(1,468 Views)