Re: challange

new topic     » goto parent     » topic index » view thread      » older message » newer message

Thanks Irv, I thought I would learn something from this. I didn't know about
the onChange[] = nil.... I'll try your rtn over the weekend. I'm off to the
boat with my laptop to get away from the support phone in about an hour....

...george

----- Original Message -----
From: "Irv Mullins" <irvm at ellijay.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: challange


>
> On Friday 24 August 2001 10:33, George Walters wrote:
> >
> > I've taken a cut (not a very good one) to print a date mask into a
editText
> > field and use onChange() to collect what is typed into the field and
wrap
> > the numbers around the slashes. See if you can do a better job than me.
If
> > you can't maybe you can use the rtn.
> >
> > It does not validate that what is entered is a date. That woud have to
be
> > done with a onLostFocus() event. This just collects the numbers.
>
> Here's one that might work. It ignores anything but 0..9, and adds the /
's
> at the appropriate places. It could be extended to accept short numbers
> separated by slashes, i.e.
> 1/2/01.
>
> --  code generated by Win32Lib IDE v0.10.5
>
> include Win32lib.ew
> without warning
>
>
> procedure EditText2_onChange ()
> object text
> integer lastchar,x
>  onChange[EditText2] = nil -- don't respond to change events.
>  text = getText(EditText2)
>  if length(text) > 0 then
>     lastchar = text[length(text)]
>     x = find(lastchar,"0123456789")
>     if x > 0 then
>      if length(text) = 2
>      or length(text) = 5 then
>         text &= "/"
>      end if
>     else text = text[1..length(text)-1]
>     end if
>  end if
>  setText(EditText2,text)
>  setIndex(EditText2,-1) -- done with changes, reenable event trap:
>  onChange[EditText2] = routine_id("EditText2_onChange")
> end procedure
> onChange[EditText2] = routine_id("EditText2_onChange")
>
> WinMain( Window1, Normal )
>
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu