harefort - you'd have to cast the string to an integer/float first; and you then run into problems with certain time literals such as 't', 'f', etc. (i.e. ' "f" as integer ' will happily evaluate)

thatoneguy's (*waves*) solution is better, although I'd turn it around and filter only for known-allowed characters in this case (i.e. 0-9 and . or , depending on locale; best would be grabbing the decimal separator from the registry - HKEY_CURRENT_USER\Control Panel\International::sDecimal )

DaveWortley

03-24-2009, 07:24 PM

I could also do the obvious thing of using a spinner instead which I can limit to Float/Integer easily!

But thanks for the code anyway, I'll need it for some of them.

D

ZeBoxx2

03-24-2009, 08:37 PM

you could, but then you wouldn't be answering your own question ;)

besides... then you'll have to figure out how to hide the spinner controls - and keep them hidden. Unless it's meant to be a spinner in the first place :)

other than using .NET - especially if this if for text entry into a text control anyway (as .NET gives you the character entered and you can parse that character specifically)? Not really.

Though I would go with findString in this case - simply because matchpattern will cause issues if the string to be checked has * or ? characters in it.

Note also that this isn't a full solution insofar as numbers goes. You'd have to check for period vs comma (as per the aforementioned), double-existence of them and allow the minus character (probably).

That's why a spinner -is- rather convenient, as it does all that for you.

martroyx

03-25-2009, 05:03 AM

"f" as integer ' will happily evaluate
good to know :thumbsup:

CGTalk Moderation

03-25-2009, 05:03 AM

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.

Follow Us On:

The CGSociety

The CGSociety is the most respected and accessible global organization for creative digital artists. The CGS supports artists at every level by offering a range of services to connect, inform, educate and promote digital artists worldwide. More about us on TheArtSociety.com