decimal point notation problem

Hi,

I’m in the Netherlands. My decimal separator is a , so 0.1 becomes 0,1.

I read values from a set of sliders having values ranging from 0 to 1.
I control an external program via a “do shell” command. As such that works fine.
However, the external binary expects a 0.1 instead of a 0,1. How do I always give a 0.1 (or 0.2 or 0.3 etc) to my external binary no matter what spot on Earth I am?

Currently I use (one example)

	
.. more slider values
set wSaturation to "--wSaturation=" & content of slider "wSaturation" of tab view item "Enfuse" of tab view "TabView" of window "main"
.. more slider values

That doesn’t work, but to give you an impression what I’m doing.

Hi,

the problem is the coercion to text

two suggestions to convert the values


property commaSeparator : false
-- .
set commaSeparator to (1 as real as text) contains ","

--.
set x to 2 as real as text
set y to convert1(x)
set z to convert2(x)

on convert1(x)
	if not commaSeparator then return x
	set {TID, text item delimiters} to {text item delimiters, ","}
	set x to text items of x
	set text item delimiters to "."
	set x to x as text
	set text item delimiters to TID
	return x
end convert1

on convert2(x)
	if not commaSeparator then return x
	set o to offset of "," in x
	tell x to return text 1 thru (o - 1) & "." & text (o + 1) thru -1
end convert2

Thanks for your reply. However I can’t make it work. I have now in my script


property commaSeparator : false

set commaSeparator to (1 as real as text) contains ","
..
..
..
set wExposure to "--wExposure=" & convertseparator(content of slider "wExposure" of tab view item "Enfuse" of tab view "TabView" of window "main")

..
..
..
(* on convertseparator(x)
	set commaSeparator to (1 as real as text) contains ","
	
	if not commaSeparator then return x
	set o to offset of "," in x
	tell x to return text 1 thru (o - 1) & "." & text (o + 1) thru -1
end convertseparator *)

on convertseparator(x)
	if not commaSeparator then return x
	set {TID, text item delimiters} to {text item delimiters, ","}
	set x to text items of x
	set text item delimiters to "."
	set x to x as text
	set text item delimiters to TID
	return x
end convertseparator

I tested both (as you can see) and used a “display dialog wExposure” to check . I still get a “–wExposure=0,3” value (for example). Am I overlooking something?

I think so,

 set {TID, text item delimiters} to {text item delimiters, "."}

must be

set {TID, text item delimiters} to {text item delimiters, ","}

as in my post
:wink:

Sorry,

I just edited my post to change it back. I had your original version in my script, but that didn’t work. So, as I did not understand the script completely I changed it to a “.” . This didn’t work either (as you knew off course).
I then copied that part back into my reply which led to the confusion. I’m sorry. (That’s two times sloppy in a row).
However, both original versions don’t work.

hm, I tested it not with Xcode, but with the dutch number format.
Another idea: without any use of my suggestions, what value do you get with

string value of slider "wSaturation".

The string value works great !

Thanks a lot for your help.