AltiumScriptCentral icon indicating copy to clipboard operation
AltiumScriptCentral copied to clipboard

Draw Polygon. Error parse dot in number.

Open qywx opened this issue 10 years ago • 8 comments

2 This is because my localized separator is comma. All works normally with it. Since Altium supports both separators it should be cool to make script "eat" both too.

qywx avatar Sep 20 '15 13:09 qywx

I have solved it with

...
' Line thickness
' check locale
if( CStr(0.1) = "0,1" ) then
    EditLineThicknessMm.Text = (Replace(EditLineThicknessMm.Text,".",","))
end if
If Not IsPerfectlyNumeric(EditLineThicknessMm.Text) Then
...

qywx avatar Sep 20 '15 14:09 qywx

Thanks for reporting this bug and presenting a solution! I will add it to the code soon.

gbmhunter avatar Sep 24 '15 10:09 gbmhunter

Weird, I tried finding the exact reason why IsPerfectlyNumeric() function in Utils.vbs would be returning false, as all the tests inside that function are meant to be locale-aware (i.e. understand that you use a comma for the decimal separator).

I tried change my locale to something that uses a comma with SetLocale(3079) (this changes the locale to Austria), however I couldn't get the code to recognise the comma.

@sledgeh, would you be able to determine what part of the IsPerfectlyNumeric() function in Utils.vbs is returning false? There are three if statements in that function.

gbmhunter avatar Sep 25 '15 00:09 gbmhunter

I will.

qywx avatar Sep 25 '15 17:09 qywx

IsNumeric("1.2") returns false

qywx avatar Sep 25 '15 20:09 qywx

IsNumeric("1.2") returns true for me, presumably because my locale supports the period the . while yours supports the comma (,).

However, this still supports the theory that the IsPerfectlyNumeric() function should work correctly for both locales. Would you be able to provide info on which part of IsPerfectlyNumeric() returns false for a number such as 1,2 (note that's a comma, not a period as you mentioned above) on your system.

gbmhunter avatar Sep 27 '15 20:09 gbmhunter

which part of IsPerfectlyNumeric()...

I supposed my answer was clear.

IsNumeric("1.2") returns false

And since it is part of IsPerfectlyNumeric(), IsPerfectlyNumeric() returns false.

showmessage IsPerfectlyNumeric("1")          'true
showmessage IsPerfectlyNumeric("1.2")        'false
showmessage IsPerfectlyNumeric("1,2")        'true
showmessage IsNumeric("1.2")                 'false

qywx avatar Sep 28 '15 20:09 qywx

What about my pull request? It provides valid fixes.

qywx avatar Oct 09 '15 14:10 qywx