LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

decimal separators

hello ,
nice to see you here. i have a problem with the reading  and writing  the data in different formats of decimal separators(usually comma and a dot). 
My task :
i have to write a labview program which can read  (dot or comma ) decimal separator file and write the data  in (dot or comma) and depending on the german or english OS.
for eg :
 steps:
 1. Find the decimal separator and depending on dot or comma  , choose one of the following
 2. 2D array [1.23  2.34 ] should be written as [1,23 2,34] or [1.23 2.34] 
    and also if the data is [1,23 2, 34]  should be written as [1,23 2,34] or [1.23 2.34] .
note:
1. i shouldnot lose the precision of the output data.
 2.I should include all the four cases in my program .
 please help me out iam still  learning labview . please also provide a  program that would add clearly to your suggestions . 
 thanks again.
0 Kudos
Message 1 of 20
(7,188 Views)
Hello renault,

to detect the system decimal point you can use the structur in the picture.

For saving:
Normally I only use the "English" decimal point (that is ".") as most other programs can import numbers regardless of the used decimal point setting. If you really want to save in both settings you have to make a replace-vi that replaces all dots with commas or vice-versa.


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 20
(7,169 Views)
hello gerd ,
iam using labview 7.00  and MS XP operating sytem. The example  didnt work even after interchanging the  comma and dot  of floating point numbers in the conditional statement. there are some errors like  missing terminal in true or missing terminals in false  and missing one of the inputs in frac/string to number.
0 Kudos
Message 3 of 20
(7,147 Views)
Hello renault,

here's the vi... It works for me and should also for you.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 20
(7,135 Views)
Hello Gerd ,
 thank  you for the explanation. i was away for  a while from this work and now iam back.
 i am attaching my program so as to have a clear work of what i have done .
 
 In this program iam trying to compare the strings to find the decimal point  character in the *** finding the decimal separator ***.Even though the characters are the same .,the equal statement is executing false. please check the part once and give a solution for this .
really waiting for it.
 thanks for the suggestions .
 
0 Kudos
Message 5 of 20
(7,112 Views)
Hello Gerd ,
 thank  you for the explanation. i was away for  a while from this work and now iam back.
 i am attaching my program so as to have a clear work of what i have done .
 
 In this program iam trying to compare the strings to find the decimal point  character in the *** finding the decimal separator ***.Even though the characters are the same .,the equal statement is executing false. please check the part once and give a solution for this .
really waiting for it.
 thanks for the suggestions
0 Kudos
Message 6 of 20
(7,108 Views)
Hello renault,
the login in convert.vi is not effective for your needs. You should instead:
1) find what is the current decimal separator: this can be done like suggested by GerdW, in any case you should format to a string a constant value, not the values read from your file (I use normally 1.1 and then I pick up the middle character)
2) if the separator is a dot, you should search and replace ALL commas in the read text and change them to dots
    if the separator is a comma, you should do the reverse
I hope that your original file is not comma separated, otherwise this method would not work.
In convert.vi, you are not comparing two characters, but two strings that are unlikely to be the same; they are certainly different if there is a fractional part and the separator in the file is different from the Windows separator, because your first conversion string-to-number fails in this case (the fractional part is lost).
Hoping it's useful for you

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 20
(7,105 Views)
hello Paolo and Gerd,
my  read file is a 'comma' decimal separator and the usual windows separator is  also 'comma'.
I used here the 'frac/string to number'  and then  'number to engineering string' and compared it with the character string coming out from the file.
I assumed that only first string is compared in '=' statement.
:
How to check the decimal point separators in the above scenario. please go through the above program once more and please modify it and post the solution. iam also posting the data file that was given to me . thanks in advance
 
0 Kudos
Message 8 of 20
(7,076 Views)
Hello renault,

sorry but the file seems to be empty...


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 20
(7,070 Views)
here is the file Gerd.
0 Kudos
Message 10 of 20
(7,069 Views)