Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Help needed with Conditional Mask

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help needed with Conditional Mask

    I have a small table that has a phone field (H_PHONE) of 14 characters. Phones with area codes are to be formatted as: (123) 456-7890, while those that don�t have one are to look like this: 456-7890.

    I set the Field Rules up for a conditional mask. The first condition is that the mask look like this: 000-0000 if the following is true: LEN(ALLTRIM(H_PHONE)) = 7. The second condition is that the mask is to look like this: (000) 000-000 if the following is true: LEN(ALLTRIM(H_PHONE)) = 10.

    Once the string of numbers is entered into the field and I hit Enter or Tab, moving the cursor to the next field, the phone field simply remains as a string of numbers; that is to say no mask, no format. If I give focus back to the field and then move on, it will then display itself with the appropriate mask in place.

    I think that I�m missing something here. If you set a conditional mask, won�t it be based on that same field�s content/criteria a good part of the time? Can this be accomplished through Field Rules, without using XBasic or a custom form?

    Help � nay, insight! � would be welcome here. Thanks.

    Regards,

    Geoff Hollander

    #2
    RE: Help needed with Conditional Mask

    Geoff:

    I haven't done a conditional mask so this is just guesswork ... looking at your expression

    LEN(ALLTRIM(H_PHONE)) = 7

    I wonder if you are storing the literal - in the field? If so, then the expression might need
    LEN(ALLTRIM(REMSPECIAL(H_PHONE))) = 7

    Finian
    Finian

    Comment


      #3
      RE: Help needed with Conditional Mask

      I get that once in awhile as well, for the ONDEPART action for the field in question put a "parentform.resynch()"

      Should fix itself with that.

      Mick

      Comment


        #4
        RE: Help needed with Conditional Mask

        Correct me if I'm wrong but I don't see how you can base a conditional mask on the field that is being entered. I just tried it on a 16 character field and defined one mask for len(trim(fieldname))"10 and another for >=10. The mask for "10 only contained 9 mask characters. When entering a new record, the result is always

        Comment


          #5
          RE: Help needed with Conditional Mask

          Wouldn't it be great if the world would come up with 1 consistent phone numbering system or postal code system?

          And while we're at it, have one Television standard (well we are at least moving towards that one in the digital age!) and DVD's with out Region Codes....

          --Ira
          Regards,

          Ira J. Perlow
          Computer Systems Design


          CSDA A5 Products
          New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
          CSDA Barcode Functions

          CSDA Code Utility
          CSDA Screen Capture


          Comment


            #6
            RE: Help needed with Conditional Mask

            Thanks everyone.

            I tried the first two solutions and no go. Cal, I think that you're right, the field rule can't anticipate the data that needs to be used in its own conditional statements.

            I thought that maybe there would be some kind of automatic resynch sort of thing that would take place upon leaving that field for the next one; and thereby, SHAZAMMM the conditional parameters would kick in.

            Best Regards,

            Geoff Hollander

            Comment


              #7
              RE: Help needed with Conditional Mask

              Geoff,
              This is probably more work for the user than desired, but you could have a field (AREACODEYN) 1 byte, checkbox entry defaulting to "Y". That field could be the condition that you test on when entering the phone. When user has no area code, checks the "N".

              Comment


                #8
                RE: Help needed with Conditional Mask

                Could we not test the field's contents on the way out using the can_depart event?

                remspecial(alltrim(a_field_value)

                would (most of the time unless a user had typed something peculiar) yield either

                1234567, or
                1234567890

                which you could then format (conditionally according to length) with ( ) or - or spaces or whatever.

                Haven't tried it, though.

                Bill
                Bill Hanigsberg

                Comment


                  #9
                  RE: Help needed with Conditional Mask

                  Hi everyone,

                  This works.

                  Define the following global function:

                  =============================================
                  function format_phone as C(input_string as C)

                  tmpstr = alltrim(remspecial(input_string))

                  select
                  case len(tmpstr) = 7
                  tmpstr = left(tmpstr,3)+"-"+right(tmpstr,4)
                  case len(tmpstr) = 10
                  tmpstr = "("+substr(tmpstr,1,3)+") "+substr(tmpstr,4,3)+"-"+right(tmpstr,4)
                  case else
                  tmpstr = input_string
                  end select

                  format_phone = tmpstr

                  end function

                  ===========================================
                  From the interactive window:

                  output = format_phone ("514 123-4567")
                  ?output
                  = "(514) 123-4567"

                  output = format_phone ("1234567")
                  ?output
                  = "123-4567"

                  output = format_phone ("5141234567")

                  ?output
                  = "(514) 123-4567"

                  ============================================
                  Define this field rule for the can_write_field event of the phone field:

                  a_field_value = format_phone (a_field_value)

                  Obviously you could further elaborate the function as necessary.

                  Bill
                  Bill Hanigsberg

                  Comment


                    #10
                    RE: Help needed with Conditional Mask

                    Hi Bill,

                    Just because I like to bust your chops, here is a better function! :?)

                    function format_phone as C(input_string as C)

                    tmpstr = alltrim(remspecial(input_string))
                    lentmp=len(tmpstr)

                    if lentmp=10
                    tmpstr=mask(tmpstrg,"(...)|...-....")
                    else if lentmp=7
                    tmpstr=mask(tmpstrg,"...-....")
                    else
                    tmpstr=input_string
                    end if

                    format_phone=tmpstr

                    end function


                    Spaces are to be placed where "." appears above.

                    This variation shows 3 (maybe 4) important differences in XBasic methods for speed.

                    1. Never cover the same ground twice -len(tmpstg)is calculated only once
                    2. Always put the most probable outcome 1st (except for possibly default cases), in this case I'll assume it is 10 digit phone numbers.
                    3. Use the simplest built-in functions and use them the minimum amount that accomplishes the job. In this case it's the MASK() function

                    and finally,

                    4. Ask Ira what a better way to do it is! (OK this is not really an XBasic method)

                    Regards,

                    Ira J. Perlow
                    Computer Systems Design & Associates
                    [email protected]
                    Regards,

                    Ira J. Perlow
                    Computer Systems Design


                    CSDA A5 Products
                    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                    CSDA Barcode Functions

                    CSDA Code Utility
                    CSDA Screen Capture


                    Comment


                      #11
                      RE: Help needed with Conditional Mask

                      Hi Bill,

                      Oh, and I just noticed that the ALLTRIM is redundant with the REMSPECIAL, so it becomes;

                      function format_phone as C(input_string as C)

                      tmpstr=remspecial(input_string)
                      lentmp=len(tmpstr)

                      if lentmp=10
                      tmpstr=mask(tmpstrg,"(...)|...-....")
                      else if lentmp=7
                      tmpstr=mask(tmpstrg,"...-....")
                      else
                      tmpstr=input_string
                      end if

                      format_phone=tmpstr

                      end function


                      Spaces are to be placed where "." appears above.

                      Regards,

                      Ira J. Perlow
                      Computer Systems Design & Associates
                      [email protected]
                      Regards,

                      Ira J. Perlow
                      Computer Systems Design


                      CSDA A5 Products
                      New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                      CSDA Barcode Functions

                      CSDA Code Utility
                      CSDA Screen Capture


                      Comment


                        #12
                        RE: Help needed with Conditional Mask

                        Hello Ira,

                        I kwew you would have something to add. In fact, I had planned to include in my little contribution the sentence,
                        "I hope Ira will be proud of me for doing this with a function."

                        But I forgot.

                        I completely forgot about the mask function. Of course, our little issue here is just what it's for.

                        As for busting my chops, you are welcome to do it. This board has such wonderful colleagueship and cooperation that we (at least I) are miles ahead for it.

                        Thanks for the improvement and-especially-the statement of principles.

                        Bill
                        Bill Hanigsberg

                        Comment


                          #13
                          RE: Help needed with Conditional Mask

                          For what it's worth:

                          We in the Philadelphia area now have to dial all ten digits of a phone number, even if it is in our own area code. This is because we now have overlay area codes which means that there can be two (or possibly) more area codes for one region. This is because of the explosion of new telephone numbers. We already suffered through a split of area codes 5 or 6 year ago.

                          The reason that I am writing this is because I think it would be a good idea to put in area codes right from the start, regardless of whether or not you need them now, as you may face the same problem we have. You could always have the for display them without the area code if it is a local number, but you may find yourself needing to put them back in later if you do not do it now.

                          Jay Talbott
                          Jay Talbott
                          Lexington, KY

                          Comment


                            #14
                            RE: Help needed with Conditional Mask

                            Jay,

                            You give wise advice. My wife is in the phone business and what is today true for Philadelphia will soon be the case everywhere, at least everywhere in North America.

                            The term "area code" is now a misnomer, given that your next-door neighbor can have a different 3-digit prefix. The only advantage is that we are told that we will be able to keep the same phone number when we move. So you could come up here to Montr�al and keep your old number. At least that is how it is supposed to work.

                            But by then Bill Gates will probably have purchased the phone companies, phone numbers will be a part of windows and Linux users will have to purchase pigeons.

                            Bill
                            Bill Hanigsberg

                            Comment


                              #15
                              RE: Help needed with Conditional Mask

                              I agree with you, Jay. Southeast Michigan (Detroit) used to be the 313 area code (I think - it's been a long time since it was only one). Now it's the 313, 810, 248, and 734 area codes with another split coming soon.

                              Between home, office, and cell phones, I personally have phone numbers in 3 area codes as do many people that I call on at DaimlerChrysler. (You would think that a company the size of DCX could get their pagers in the same area code as the company's office!)

                              Cal

                              Comment

                              Working...
                              X