Alpha DevCon 2018
Results 1 to 9 of 9

Thread: Mask XDialog Input

  1. #1
    "Certified" Alphaholic
    Real Name
    Charlie Crimmel
    Join Date
    Apr 2000
    Location
    West Virginia
    Posts
    1,695

    Default Mask XDialog Input

    Is there a way to mask Xdialog input
    for the code below I want the (-) dashes to be like a field rule mask

    the user would enter 0511110
    and it would be formatted in the xdialog so the user would see
    05-1111-0

    Thanks
    Charlie Crimmel

    dim global vempnum as c
    trace.clear()
    'Prompt for any ASK variables in filter/order expressions......
    ask_vars = <<%list%
    Askc_Enter_empnum
    %list%
    prompt_result = a5_prompt_for_ask_vars(ask_vars,session_variables(session_get()))
    if prompt_result <> "OK" then
    end
    else
    var->vempnum=Askc_Enter_empnum
    trace.WriteLn("empnum = " + var->vempnum)
    end if
    Last edited by Al Buchholz; 07-29-2017 at 05:02 PM.

  2. #2
    VAR
    Real Name
    Cheryl Lemire
    Join Date
    Jul 2003
    Location
    Pembroke Pines, FL
    Posts
    2,914

    Default your answer is in the help files

    I did a simple search on xdialog, scrolled down the list which is alphabetical and found: Mask

    http://support.alphasoftware.com/alp...alog_Field.htm

    Good luck
    Cheryl

  3. #3
    "Certified" Alphaholic
    Real Name
    Charlie Crimmel
    Join Date
    Apr 2000
    Location
    West Virginia
    Posts
    1,695

    Default

    Thanks, but not exactly what I am trying to do.
    If I use UI_Get_text
    the format below puts the dashes in so the user does not have to type them
    I would like the xdialog to do the same.

    text_string = ui_get_text("empnum", "Enter Employee Number for Selection"," ","&&-&&&&-&")
    IF text_string = " " THEN
    ui_beep()
    ui_msg_box("empnum", "Employee Number invalid.")
    END
    ELSE
    var->empnum = text_string
    END IF

  4. #4
    VAR
    Real Name
    Cheryl Lemire
    Join Date
    Jul 2003
    Location
    Pembroke Pines, FL
    Posts
    2,914

    Default

    'declare vars for use in the dialog
    dim global vcgSSno as C
    vcgSSno = space(11)

    ssnum = ""

    {sp=5} Enter Social Security Number: |[11.15ssnum!ssnum_killfocus]| 9 digits, no hyphens ;
    {lf};

    case "ssnum"$ui_dlg_ctl_current("Create a New Accession Case") 'ssnum Textbox has focus
    if a_dlg_button = "enter" then 'force focus to move to &OK control,
    a_dlg_button = ""
    vclSsNum = remspecial(ssnum)
    if len(alltrim(vclSsNum))=9 then
    ssnum = left(vclSsNum,3) + "-" + substr(vclSsNum,4,2)+ "-" + right(vclSsNum,4)
    sys_send_keys("{TAB}")
    end if
    elseif a_dlg_button = "ssnum_killfocus" then 'insert the hyphens for the user
    'note: killfocus event fires on each keystroke
    ' while ssnum has focus
    a_dlg_button = ""
    vclSsNum = remspecial(ssnum)
    if len(alltrim(vclSsNum))=9 then
    ssnum = left(vclSsNum,3) + "-" + substr(vclSsNum,4,2)+ "-" + right(vclSsNum,4)
    end if
    end if

  5. #5
    "Certified" Alphaholic
    Real Name
    Charlie Crimmel
    Join Date
    Apr 2000
    Location
    West Virginia
    Posts
    1,695

    Default

    I am able to format the user input
    The same concept works for ssn and phone numbers
    Thanks

    trace.clear()
    dim global empnum as c
    var->empnum=""
    Result = ui_dlg_box("EMPNUM",<<%dlg%
    {region}
    EMPNUM:| [.30empnum!empnum_*]
    {endregion};
    {region}
    <*15&OK> <15&Cancel>
    {endregion};

    %dlg%,<<%code%
    '----------------
    if len(alltrim(empnum))= 2 then
    first2 = substr(empnum,1,2)+"-"
    var->empnum = first2
    end if
    if len(alltrim(empnum))= 7 then
    second4 = substr(empnum,4,4)+"-"
    var->empnum = first2+second4
    end if
    if len(alltrim(empnum))= 9 then
    third1 = substr(empnum,9,1)
    var->empnum = first2+second4+third1
    end if

    '----------------
    if a_dlg_button = "&OK" .or. a_dlg_button = "&Cancel" then
    trace.WriteLn("EMPNUM = " + var->empnum)
    'do nothing, dialog will close
    else 'the event has not been handled, so set a_dlg_button to "" to keep the dialog open
    a_dlg_button = ""
    end if
    %code%)
    end

  6. #6
    Member
    Real Name
    Dragan Milosavljevic
    Join Date
    Mar 2010
    Location
    Belgrade, Serbia
    Posts
    79

    Default Re: Mask XDiaglog Input

    I have a similar problem.
    How to mask form field based on character variable.
    Display must look like : 199-007-07.
    We want to ensure that the user do not have to type the dashes (-).

  7. #7
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,126

    Default Re: Mask XDiaglog Input

    Place this on the form field CanDepart event, replacing what's in red with the name of your field:

    Code:
    dim vF as C
    vF=alltrim(topparent:field1.value)
    topparent:field1.value=substr(vF,1,3)+"-"+substr(vF,4,3)+"-"+right(vF,2)
    You can do this with the mask table field rule, but I shy away from field rules.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  8. #8
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,992

    Default Re: Mask XDiaglog Input

    Using Mike's logic you could also

    Code:
    topparent:field1.value = mask(vF,"   -   -  ")
    Where the mask has three spaces, a dash, three spaces, a dash, and two spaces inside the quotes.

  9. #9
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,393

    Default Re: Mask XDialog Input

    Gotta love old threads if you can find them! Interestingly, there is not an XD smart field to help format text input like there is for dates and such
    See: Xdialog Smart Fields.

    Although you could use %P=ui_get_text() to add the format string - it pops up another dialog.

    So this is my modification to see a SSN formatted as the user types it in:

    Code:
    dim vSSN as c
    vssn=""
    Result = ui_dlg_box("Format SSN",<<%dlg%
    {region}
    SSN:| [.20vSsn!evSsn_*]
    {endregion};
    {region}
    <*15&OK> <15&Cancel>
    {endregion};
    
    %dlg%,<<%code%
    if a_dlg_button = "evssn_change" then
    	vSSN = mask(remspecial(vSSN),"   -  -    ")	
    end if
    '----------------
    if a_dlg_button = "&OK" .or. a_dlg_button = "&Cancel" then
    trace.WriteLn("SSN = " + var->vSSN)
    'do nothing, dialog will close
    else 'the event has not been handled, so set a_dlg_button to "" to keep the dialog open
    a_dlg_button = ""
    end if
    %code%)
    end
    If you add the %N% directive, the killfocus event could be used, but you would only see the change when the control loses focus. And without the %N% directive you won't see the killfocus event do anything...

    By using the change event and remspecial() in conjunction with the mask(), the control updates properly. And now that area codes are required for dialing all phone numbers, this could easily be adapted for that use too.

    Edit: Just noticed that Xdialog was spelled wrong - probably explains why this thread was so hard to find!
    Last edited by Al Buchholz; 07-29-2017 at 04:59 PM. Reason: fixed spelling.. for Robin.. ;)
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. [Field Rules] Cannot input Simple mask
    By Maurice van 't Loo in forum Alpha Five Version 5
    Replies: 4
    Last Post: 02-25-2004, 03:02 PM
  2. Date input mask
    By Gerry Duggan in forum Alpha Five Version 5
    Replies: 6
    Last Post: 02-19-2004, 03:56 AM
  3. Mask
    By Walter in forum Alpha Five Version 5
    Replies: 2
    Last Post: 06-25-2003, 04:32 AM
  4. Mask
    By russ Boehle in forum Alpha Five Version 5
    Replies: 0
    Last Post: 03-25-2003, 11:44 AM
  5. field mask?
    By Ludwig Beil in forum Alpha Five Version 5
    Replies: 2
    Last Post: 11-12-2002, 01:50 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
  •