CDbl in French?

I have a Rhinoscript that reads a .ini file. But Rhinoscript doesn’t recognize the numerical result as a number if Rhino is running in French. Works perfectly in English.

If the input number from the ini file is an integer, there is no error, but if it is not, then this happens in the case where arrDensity(Y)=1.2:
Box pops up that says “Type incompatible CDbl” related to the line "Density = CDbl(arrDensity(Y)). I had Rhino pop up a box on the line above and it reports the value of arrDensity(Y) as “1.2”, but Rhinoscript seems to think this is not translatable to a double. I’m assuming this is because of “1.2” instead of “1,2”, but I don’t see how to fix this in my script.

Here is the bit (I can send it all if it helps…) arrDensity is read from the .ini file earlier in the script:

						Dim Y, TestMaterial, Density			
						Y = 0
						For Each TestMaterial In MaterialOptions
							If ObjectMaterial = TestMaterial Then
								Rhino.messagebox arrDensity(Y)
								Density = CDbl(arrDensity(Y))
							End If
							Y = Y + 1
						Next

From my old VB script days -

Use the commands SetLocale() and GetLocale() to globally set the script the script for US/Euro. Changes things like decimal - commas or periods,etc.

So if I recall correctly, you need to use SetLocale(1036) for French at the beginning of the script. You can get the language Rhino is running in with Rhino.LocaleID. I don’t think it’s necessary to reset the locale after the script ends.

So, if I set the lacale to French, what will happen? I guess I’ll just try it out & find out, but I don’t know if I need to test it with Rhino running in french or with Rhino & windows running in french?

I’ll just try switching the locale & see if it fixes it. Thanks.

Good question - I honestly don’t remember, but my impression is that it is Windows that is the problem, so you would need to test it on a French Windows. If you have Win 10, you can actually download and install another language. I have a computer that has windows in English, German and French under 3 different user accounts here for my students.

SetLocale and GetLocale are vbscript native functions, not Rhinoscript methods. But they work in Rhinoscript.

I just dredged up one of my old scripts and I see that it’s the opposite of what I thought. At the beginnning of the script, I used SetLocale(1033) to make sure all the numerical values were interpreted using decimal points. At the end of the script I set it back as well…


'sets VBScript in US - looks for decimal points, plus stores the original local
origLoc=SetLocale(1033)  

<script here>

'resets VBScript in original location
Call SetLocale(origLoc)

You can of course do a find-and-replace for commas in any input values…

Oh I see. Thanks!