Alpha Video Training
Results 1 to 18 of 18

Thread: need help regarding mask

  1. #1
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default need help regarding mask

    hello,

    I have a field ID_NO of YYMMDD-00-0000 where the year, month and day are in that order followed with numerical number 0-9 for the last 6 digits. The middle 2 digits are state number. I could use the simple mask in field rules as 000000-00-0000, but this would not prevent error while entering the information.
    Is there any other way?

    Any info and help is appreciated.

  2. #2
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: need help regarding mask

    I'd probably use 3 fields.

    In one I'd collect the "date"; no mask required.
    In the second I'd collect the "00-0000" portion with a mask.
    I'd use field rules to populate the third with a calculated expression that converts and combines the first two fields.

    I don't think you can use a mask to validate the entry of "date" values. If you collect the "date" portion separately, as a "date" type field value, Alpha will detect and block invalid inputs.

  3. #3
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Hello Tom,

    Thanks for your instant help.
    I will follow your advise.

    Thanks again.

  4. #4
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Hello Tom,

    I have create DOB2 field for 000000, IC1 for 00, IC2 for 0000 and IC calculated field. All are C type. I use CanEditField event ( dtoc(dob,"2-") ) on DOB field rule to get the proper date required. Then in the form, OnDepart event of DOB i use action script: get values to vc_dob, then set the value to dtoc(vc_dob,"2-"), then set value for field DOB2 with right(cdate(vc_dob),6).
    I use alltrim(dob2)+"-"+alltrim(ic1)+"-"+alltrim(ic2) into the calculated field of IC.

    Its works well. However i tried another way, creating 3 field variables on the form instead of the dob2, ic1 and ic2 on the table. I got error on the calculated IC field expression. Can this be done?
    I am trying to cut off unnecessary fields in table.

    Any help is appreciated.

  5. #5
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: need help regarding mask

    Here's an example that may help.

    Unzip the attachment to an empty folder.

    Open the database and then FORM1.

    Let me know if you have questions.

  6. #6
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Tom,

    Thanks again for prompt assist.
    Yes, that's what i was looking for, except i need to remove the first 2 digit of the year. I,ll work on it. If not I'll post question again.

    My Xbasic is very poor. I am learning from help files and forums.

    Thank you for the help.

  7. #7
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: need help regarding mask

    Ok,

    I've extended the example to trim the YYYYMMDD to YYMMDD, and to show you how one might do this using action scripting.

    Double check the field width for the IC field I'm using it may be different from yours.

    -- tom

  8. #8
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Hello Tom,

    Thanks again for the great help.
    It seems Xbasic is more simpler than the action scripts. However action scripts are much easier to understand.
    I did modify the xbasic push1 button for the :Form1:Ic.text = right(dtos(var->dob),6) + "-" + ltrim(str(var->ic1,2)) + "-" + ltrim(str(var->ic2,4))

    with :Form1:Ic.text = right(cdate(var->dob),6) + "-" + ltrim(str(var->ic1,2)) + "-" + ltrim(str(var->ic2,4))
    it work.

    I have read threads in forum, some say better use cdate than others as it will not clash with the system date?

    In the push buttons, end up with save record. Is it necessary to save record every push events? Why not let other save button do it?

    Thanks again.

    From
    Razali

  9. #9
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: need help regarding mask

    In the push buttons, end up with save record. Is it necessary to save record every push events? Why not let other save button do it?
    No, it's not necessary to have the button push event save the record. Whether to commit the change on the button push, or at some later point is up to you. You may even decide to use a different "event" to do this work, instead of using a button push. My example was not intended to be a recommended total solution for your data entry needs, just an example of how to collect input in variables and then assign them to a table field displayed on form.

  10. #10
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Dear Tom,

    Thanks for tips and advice. Your samples are valuable especially to newer person
    in database and alpha 5 like me. A lot i have learned from you. From proper way of setting action scripts to its xbasic comparison.

    I certainly need it in my application.
    Thank you very much.

    from
    Razali

  11. #11
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Tom,

    I need your help again.
    How to fix the length of the variable field object in the form?

    The format display properties only format the length of display. When typing in the field, no restriction on the length and one could make error. Not like field table, where limit the characters numbers.

    thanks.

    From
    Razali

  12. #12
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: need help regarding mask

    Check my example. When the script concatenates the variable values I include only portions of whatever string the user may have entered.

    This situation illustrates the difficulty you will have in validating input received into raw unmasked variables. Your script should check for too few chars and also for too many. Lots of work. All of this work is avoided if you use table fields and let Alpha do the validation for you. You can do it your way, it's just going to take a lot more work. You're swimming against the tide in my opinion.

  13. #13
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Tom,

    I looked at the form again and test few times, found that the variable only accept the leading portion. I guess that's acceptable.

    Actually, here, my customer usually presented with I.D. card with YYMMDD-12-3456 number. Not with DOB. Thus a user need to look carefully and type DDMMYY into the variable field.

    Thus, I create 3 variables, a DOB1, IC1 and IC2, all C types. I use your action script at the OnChange event of IC2 to get text into IC table field without the date conversion part. Then on the OnChange event of DOB field, I put the conversion date get text to the DOB1 (to double check the entry).

    Not sure if this could cause problem later.
    People do make mistake on and off. They may type wrongly on the IC1 and IC2 part.

    Thanks for the help.

    From
    Razali

  14. #14
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default Re: need help regarding mask

    I looked at the form again and test few times, found that the variable only accept the leading portion. I guess that's acceptable.
    A complete solution would check the length of the string and prompt user for corrections. The difficulty is that there are several ways the user can go wrong, all of which must be trapped in your script. If it were me I would abandon the use of variables for data entry and would use table fields with field rules, instead. Doing so takes advantage of the validation code that's already built in to Alpha Five, and avoids the need to custom craft your own input validation scripts.

    In any case good luck with your project.

  15. #15
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Hello Tom,

    I will try to use actual field then. The field rule provide a lot of functions and options.

    When done, i post again.

    Thanks.

    From
    Razali

  16. #16
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Tom,

    Here what i have done. table1:id 10C, IC 14C(not a calculated field) and DOB D8 table2: dob1 6C, IC1 2C(with lookup table for state No), IC2 4C.
    I let user type in dob1, ic1 and ic2, then OnChange event of ic2 i put the calculated expression for IC. OnChange event of DOB i put the date conversion to dob1 and calculated expression for the IC as well. In the form, i create a pushbutton to clear the field values of the dob1, ic1 and ic2 prior to save.
    I tried to rule the DOB as calculated field, but on clearing the dob1, ic1 and ic2 fields, the IC value gone too.

    I would like to make sure the user typing all 6C of the dob1, and 4C of ic2. If not the cursor will remain in the field until fully typed, without prompting error message. Can this be done?

    Thanks for your concern and help.

    From
    Razali

  17. #17
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Hello Tom,

    I found this ISBLANK("Conditional") .OR. LEN(ALLTRIM(CONDITIONAL))=10 in forum thread to be use in custom validation with message box.

    Is there any other method?

    Thanks

    From
    Razali

  18. #18
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    66

    Default Re: need help regarding mask

    Tom,

    This one works better:

    len(alltrim(field_name))=N

    From

    Razali

Similar Threads

  1. Mask ?
    By Harry Hanson in forum Alpha Five Version 8
    Replies: 4
    Last Post: 04-01-2007, 07:44 PM
  2. Mask
    By Walter in forum Alpha Five Version 5
    Replies: 2
    Last Post: 06-25-2003, 05:32 AM
  3. Mask
    By russ Boehle in forum Alpha Five Version 5
    Replies: 0
    Last Post: 03-25-2003, 12:44 PM
  4. Mask for a URL
    By Adrienne Boswell in forum Alpha Five Version 4
    Replies: 1
    Last Post: 09-22-2001, 12:58 PM
  5. Variable Mask
    By Peter.Greulich in forum Alpha Five Version 4
    Replies: 3
    Last Post: 01-09-2001, 05:24 PM

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
  •