Alpha Video Training
Results 1 to 7 of 7

Thread: restrict character input

  1. #1
    Member
    Real Name
    John Cunradi
    Join Date
    Aug 2000
    Posts
    464

    Default restrict character input

    Is it possible to dis-allow a specific character to be entered while allowing all other characters?

    I don't care if it ignores the keypress or indicates that the character is not allow via a warning popup or??.

    Thanks.

  2. #2
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,649

    Default RE: restrict character input

    I'm not sure if a field rule mask will work, it might. Otherwise use the OnKey event.

  3. #3
    "Certified" Alphaholic
    Real Name
    Cal Locklin
    Join Date
    Mar 2000
    Location
    S.E. Michigan
    Posts
    5,763

    Default RE: restrict character input

    The only issue with the OnKey event is that it applies to the whole form. If the restriction only applies to one field, you would probably have to write a script for the CanWrite field event. Something like this should work if you don't want the user to type the letter "L" or "l":

    IF atc( "L", a_field_value ) > 0
    ui_msg_box( "*** ERROR ***", "Can't do that...retype it." )
    cancel()
    END

  4. #4
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default RE: restrict character input

    Cal,

    You are correct that the OnKey event applies to the whole form (as does the OnTimer event), but that can easily circumvented. It is very easy to change the event code dynamically. In fact, both of these events should be done this way, as they both have very high overhead on system performance when not a null value.

    In the OnArrive for the field, I would put code similar to

    dim shared OnKey_orgcode as C
    OnKey_orgcode=parentform.event.OnKey
    parentform.event.OnKey="new code here as an expression"



    In the OnDepart for the field, the code would look like this,

    dim shared OnKey_orgcode as C
    parentform.event.OnKey=OnKey_orgcode


    Some people try to put a ton of code in the new code expression(which creates headaches trying to account for quotes, double quotes etc), however, I prefer to keep it simple, like 1 of the 2 below

    parentform.event.OnKey="OnKey_newcode_function_name()"

    or

    parentform.event.OnKey="script_play('OnKey_newcode_scipt_name')"

    Regards,

    Ira J. Perlow
    Computer Systems Design & Associates
    csda@mediaone.net

  5. #5
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,805

    Default RE: restrict character input

    Cal:

    With an OnKey event for a single field, you can help things along with a

    if this.active()=field_to_test then
    'code here
    else
    end
    end if

    helps keep the overhead down.

    Finian

  6. #6
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default RE: restrict character input

    Finian

    While qualifing the code with what field is active will help, I think it's effect is trivial. I believe the major amount of overhead is whether the ONKEY event is active or not (in other words the code is set to null or not). Proof of this would be seen in the responsiveness of the keystrokes.

    Regards,

    Ira J. Perlow
    Computer Systems Design & Associates
    csda@mediaone.net

  7. #7
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,957

    Default RE: restrict character input

    Ira,
    your idea is fascinating, but I can barely grasp it. could you write a short script of some simple practical use.

Similar Threads

  1. Restrict Find
    By Robin James in forum Alpha Five Version 5
    Replies: 2
    Last Post: 08-15-2003, 03:20 PM
  2. Restrict access to certain fields
    By Karla Nelson in forum Alpha Four Version 6 and Prior
    Replies: 8
    Last Post: 01-23-2003, 06:14 AM
  3. RESTRICT/LOCK RECORDS
    By jfaust in forum Alpha Five Version 4
    Replies: 3
    Last Post: 01-17-2003, 10:51 AM
  4. trying to restrict app
    By kalisto in forum Alpha Five Version 5
    Replies: 6
    Last Post: 01-01-2003, 06:13 AM
  5. Restrict Rclick
    By Michael Humby in forum Alpha Five Version 4
    Replies: 3
    Last Post: 05-05-2001, 11:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •