Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw Polygon. Error parse dot in number. #204

Open
qywx opened this issue Sep 20, 2015 · 8 comments
Open

Draw Polygon. Error parse dot in number. #204

qywx opened this issue Sep 20, 2015 · 8 comments
Assignees

Comments

@qywx
Copy link

qywx commented Sep 20, 2015

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
Copy link
Author

qywx commented Sep 20, 2015

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
...

@gbmhunter
Copy link
Owner

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

gbmhunter added a commit that referenced this issue Sep 25, 2015
… locale where ',' is used as decimal separator would cause IsPerfectlyNumeric() to return false (see issue #204).
@gbmhunter
Copy link
Owner

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.

@qywx
Copy link
Author

qywx commented Sep 25, 2015

I will.

@qywx qywx closed this as completed Sep 25, 2015
@qywx qywx reopened this Sep 25, 2015
@qywx
Copy link
Author

qywx commented Sep 25, 2015

IsNumeric("1.2") returns false

@gbmhunter
Copy link
Owner

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.

@qywx
Copy link
Author

qywx commented Sep 28, 2015

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 pushed a commit to qywx/AltiumScriptCentral that referenced this issue Sep 28, 2015
@qywx
Copy link
Author

qywx commented Oct 9, 2015

What about my pull request? It provides valid fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants