Ensuring numeric input

MisterX b.xavier at internet.lu
Thu Oct 27 10:43:25 EDT 2005


don't forget many use commas for decimal points too... 
Tildes for 1'000's etc...

cheers
X

> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com 
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of 
> Lynch, Jonathan
> Sent: Thursday, October 27, 2005 3:34 PM
> To: How to use Revolution
> Subject: RE: Ensuring numeric input
> 
> .2 is a number
> . is just a period, not a number
> 
> -2 is a number
> - is just a minus sign, not a number
> 
> 
> 
> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Ken Ray
> Sent: Thursday, October 27, 2005 12:16 AM
> To: Use Revolution List
> Subject: Re: Ensuring numeric input
> 
> On 10/26/05 10:58 PM, "Michael J. Lew" 
> <michaell at unimelb.edu.au> wrote:
> 
> > Thanks for the suggestions, but unfortunately it doesn't seem to be 
> > anywhere near that easy. A user can put the insertion point 
> within a 
> > number and so I need to check before the character is 
> entered whether 
> > the value will be a number after the new character is added at the 
> > insertion point. The new character may be at the start of a numeric 
> > string, in the middle or at the end. I can't find an easy function 
> > that gives the insertion point relative to the 
> selectedLine. Most of 
> > the complexity of my script is in deciding where the 
> insertion will be 
> > made in the line of interest.
> > 
> > Still lacking a simple solution...
> 
> Try this one (script of the field):
> 
> on keydown whichKey
>     if whichKey is among the chars of "01234567890.-" then
>         put me into tTemp
>         put word 2 of the selectedChunk into sChar
>         put word 4 of the selectedChunk into eChar
>         if eChar > sChar then -- some text is selected
>             delete char sChar to eChar of tTemp
>         end if
>         put whichKey after char eChar of tTemp
>         if isNumber(tTemp) then pass keyDown
>     end if
> end keyDown
> 
> Basically it checks to see if the end product would end up 
> with a numeric value, and if so, it will allow the keystroke 
> to happen.
> 
> BTW: There was no reason to trap for backspace/delete as 
> there isn't a way AFAIK to remove some or part of a number 
> and have the end result *not* be a number.
> 
> HTH,
> 
> Ken Ray
> Sons of Thunder Software
> Web site: http://www.sonsothunder.com/
> Email: kray at sonsothunder.com
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage 
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage 
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list