Discussion:
decimal separators
(too old to reply)
renault
2005-07-05 13:40:37 UTC
Permalink
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.
GerdW
2005-07-05 14:10:34 UTC
Permalink
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.


GetDecimal.png:
Loading Image...
renault
2005-07-18 10:10:48 UTC
Permalink
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 .
 


convert.vi:
http://forums.ni.com/attachments/ni/170/131950/1/convert.vi
renault
2005-07-18 10:10:49 UTC
Permalink
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


convert.vi:
http://forums.ni.com/attachments/ni/170/131952/1/convert.vi
renault
2005-07-05 17:40:39 UTC
Permalink
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.
GerdW
2005-07-06 07:10:36 UTC
Permalink
Hello renault,

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


Get_decimal_point_char.vi:
http://forums.ni.com/attachments/ni/170/129683/1/Get_decimal_point_char.vi
pincpanter
2005-07-18 10:40:32 UTC
Permalink
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
renault
2005-07-19 09:10:42 UTC
Permalink
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
 


05062917 Ref.txt:
http://forums.ni.com/attachments/ni/170/132172/1/05062917 Ref.txt
GerdW
2005-07-19 09:40:45 UTC
Permalink
Hello renault,

here comes the changed convert.vi.

Hope this helps.
 


convert_changed.vi:
http://forums.ni.com/attachments/ni/170/132182/1/convert_changed.vi
renault
2005-07-19 10:40:30 UTC
Permalink
Thanks very much gerd .it is running well.
But i couldnot get away from the doubts here .
In finding out a character
1. the statement always executes false  and always returns char to replace field as dot and new char/dec  char field  as comma.
2.  when i read a data file  with a dot separator, after the execution of the replace function it changes to comma separated string.
so in either case it is giving out a comma separator.
3. does this program in general work for the windows with  dot separator.?
 thanks in advance gerd.
 
 
 
GerdW
2005-07-19 11:40:36 UTC
Permalink
Hello renault,

it should work... But maybe you try this changed version?

Edited: Please change the constant (both string/numeric) to 1.5!
Message Edited by GerdW on 07-19-2005 01:22 PM


convert_changed.vi:
http://forums.ni.com/attachments/ni/170/132197/1/convert_changed.vi
pincpanter
2005-07-19 13:40:40 UTC
Permalink
The first condition in GerdW's VI can be true only when the OS decimal
separator is a dot, like (natively) under English Windows, or German
Windows with modified regional settings.
It does not depend on the file content.
At this point, I got enough confused about what you want to do: isn't
it to read numbers from a given ASCII file irrespectively of the OS
settings?
If this is your aim, GerdW's VI is what you need.

Paolo

Loading...