the UI scripting snippet below truncates a string using Applescript’s text item delimiters and works just fine for me, but apparently not for others. I get an even number result, while others get a value with decimals. I can’t understand why this very simple piece of code would behave differently on other machines running the same OS? Any suggestions?
Is the comma the decimal point symbol on your system? If so, the script won’t work on systems configured with “.” as the decimal point.
If the script does what I think it does, you probably don’t need to use text at all.
tell application "System Events" to tell process "VLC" to set the_volume to (value of slider 1 of window "VLC - Controller") * 3.125 div 1
if the_volume is 0 then
return false
else
return the_volume
end if
tell application "VLC"
repeat 32 times
volumeDown 1-- volume to zero%
end repeat
tell application "VLC"
repeat 4 times -- volume to 12.5%
volumeUp 1
end repeat
end tell
end tell
Hi Nigel,
you’re absolutely right, no need for strings. Actually I didn’t know that the decimal point depends on the system configuration, but your code does the trick nicely so the problem is solved now. Thanks a lot!
Hey Greg,
I do indeed use a repeat loop when setting the volume from within the script, but if you then change the volume manually while running the script (which is a remote controller for bluetooth devices), it messes things up. That’s why I call System Events to do the job. I should have elaborated a little on the purpose of the script, sorry about that!
Thanks both for helping out, I really appreciate it!