Source language: Translate to:

comma changing to dot or , > . when changing language

General questions about NeoBook

Moderator: Neosoft Support

comma changing to dot or , > . when changing language

Postby frednet » Tue Sep 23, 2014 2:58 pm

if I use this code to change a . into, (dot into a comma)
Code: Select all
StrReplace "[veldata1]" "[#2e]" "[#2c]" "[veldata1]" ""

and print the result to file this way
Code: Select all
FileWrite "[naamdatafile]" "Append" "[DateShort][#09][Time24][#09][kan1][#09][kan2][#09][kan3][#09][kan4][#09][kan5][#09][kan6][#09][veldata1][#09][veldata2][#09][veldata3][#09][veldata4]"
in order to make a file exel can read a strange thing happens. As you can see in the sample below the last four numbers have a dot as decimal sign.
As soon as I change the language setting in line 3 the dots become comma's at least in the last four numbers.

Code: Select all
9/23/2014   22:21:28   17,94   26,63   13,38   17,31   14,13   0   23.1   25.4   30.1   101.8
9/23/2014   22:21:38   17,94   26,63   13,38   17,25   14,13   0   23.1   25.4   30.1   101.5
23-9-2014   22:21:48   17,94   26,56   13,31   17,31   14,13   0   23,1   25,4   30,1   101,4
23-9-2014   22:21:58   17,94   26,50   13,31   17,31   14,13   0   23,3   25,4   30,1   101,9


The first six numbers are not affected by the language setting they originate from other hardware and are filtered like this:
Code: Select all
.    replace dot by comma for exel
StrReplace "[digitempwaarde]" "." "," "[digitempwaarde]" ""
.    cut string into channels for display
StrParse "[digitempwaarde]" "[#09]" "[kan]" "[aantalkanalen]"


first the dots in the raw string are replaced by comma's and next the string is broken into an array. In this case the result doe not seem to be affected by language settings.
Of course i have also tried using
Code: Select all
StrReplace "[veldata1]" "." "," "[veldata1]"
but that also does not work.
It seem arrays are treated different?

Regards Fred
User avatar
frednet
 
Posts: 83
Joined: Fri Sep 23, 2005 4:29 am
Location: netherlands

Re: comma changing to dot or , > . when changing language

Postby dpayer » Wed Sep 24, 2014 7:00 am

Would it be helpful to define your variable as a string so language settings for numbers would not apply?

From the helpfile:
DefineVar
Purpose:
Define a typed variable.
Category:
Variables
Syntax:
DefineVar "variable" "type" "format" "scope" "value"

variable - The name of the variable to be defined.
type - One of the following:
Undefined - The variable’s content is not limited. This is the same as a generic variable created with SetVar.
String - The variable can contain any characters, either alpha or numeric.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: comma changing to dot or , > . when changing language

Postby frednet » Wed Sep 24, 2014 1:32 pm

dpayer wrote:Would it be helpful to define your variable as a string so language settings for numbers would not apply?

From the helpfile:
DefineVar
Purpose:
Define a typed variable.
Category:
Variables
Syntax:
DefineVar "variable" "type" "format" "scope" "value"

variable - The name of the variable to be defined.
type - One of the following:
Undefined - The variable’s content is not limited. This is the same as a generic variable created with SetVar.
String - The variable can contain any characters, either alpha or numeric.


Hello David,
So strings are not affected by language settings that is the kind of useful information I was looking for,
Thanks ,Fred.
User avatar
frednet
 
Posts: 83
Joined: Fri Sep 23, 2005 4:29 am
Location: netherlands

Re: comma changing to dot or , > . when changing language

Postby dpayer » Thu Sep 25, 2014 7:22 am

frednet wrote:[
So strings are not affected by language settings that is the kind of useful information I was looking for,
Thanks ,Fred.


Just remember, once done, you can't do some of the simple things possible with NB's variables like SetVar "[mystringdefinedvar]" "[mystringdefinedvar]+1" and get a new number.

Language settings for numbers should not apply to a string.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: comma changing to dot or , > . when changing language

Postby frednet » Thu Sep 25, 2014 8:03 am

dpayer wrote:Just remember, once done, you can't do some of the simple things possible with NB's variables like SetVar "[mystringdefinedvar]" "[mystringdefinedvar]+1" and get a new number.

Language settings for numbers should not apply to a string.


Yes I bumped into that problem to. So your pointing to the manual made me look around and study things more.
I found the
Code: Select all
[DecimalSymbol]
variable and plan to go the other route and use this to streamline the decimal output of the exel file. It has the aditional advantage that the program will also function correctly in an other language.
Fred.
User avatar
frednet
 
Posts: 83
Joined: Fri Sep 23, 2005 4:29 am
Location: netherlands


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest