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

detecting non-numeric characters in a field

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

    detecting non-numeric characters in a field

    I have a field in a table that should have been defined as numeric when the table was established several years ago. Unfortunately, it was set up as a character field. I would like to go back now and change its type to numeric, but I want to clean up any non-numeric data that has been stored there in the mean time. Does anyone know of a function that would help me detect the soon-to-be non-conforming data? Thanks for any help.

    -Bill

    #2
    RE: detecting non-numeric characters in a field

    I believe you do this using the CHKDIGIT function, though this is not really what the function was designed for. The CHKDIGIT function will return an empty string if the character string is invalid (and a non-numeric characters would cause this).

    Try doing a query on some test data using the expression:

    Code:
    CHKDIGIT(character fieldname)=""
    I just did a test and it seemed to work fine.

    Comment


      #3
      RE: detecting non-numeric characters in a field

      isalpha might help.

      Bill
      Bill Hanigsberg

      Comment


        #4
        RE: detecting non-numeric characters in a field

        Thanks to both of you guys. I will be trying both of these functions. I knew that there had to be a way!

        -Bill

        Comment


          #5
          RE: detecting non-numeric characters in a field

          The Isalpha or Isdigit functions can be used to check a character string or field. By default these functions check the first character in a string. With a little code though, one could test every character in a character field, then step to the next field.

          Comment


            #6
            RE: detecting non-numeric characters in a field

            Expanding on Vince's idea, you could also examine the ASCII value of each character, since numbers are 048 thru 057.

            Comment


              #7
              RE: detecting non-numeric characters in a field

              Save the following as a function. Add a field to your table, calculated, = Chkold(yourfieldname).

              Sort your table on the new calculated field.


              '************************************************
              function Chkold as L(oldstr as C)
              ' Pass a character string to the function
              ' The locigal value is returned, true if it contains characters.

              'set inital to assume no letters

              Chkold = .F.
              for i = 1 to len(oldstr)
              if isalpha(substr(oldstr,i,1))
              Chkold = .T. 'if letter found, quit
              End
              End function
              end if
              next



              END
              end function
              There can be only one.

              Comment


                #8
                RE: detecting non-numeric characters in a field

                Also, decide if you REALLY need a numeric field or if you only need a character field that is limited to numerals.

                The general rule is, "Use a character field unless you will be performing math operations with the value in the field." If necessary, set up a mask to limit the type of characters accepted and use PADL or PADR if you want to have leading/trailing characters to fill the field. Leading zeros is a good idea if you want to sort 'numerically' on a character field. EX: 20 will come before 3 because 2 comes before 3; but 003 will come before 020.

                Comment


                  #9
                  RE: detecting non-numeric characters in a field

                  Would somone else verify the CHKDIGIT function?

                  I know this is not the intended purpose of the function, but I tested it several times and it worked great!

                  To use it, just do a query using the expression:

                  Code:
                   CHKDIGIT(Fieldname)=""
                  I was so excited, I always wanted to use this function but don't deal with credit card numbers or barcodes, except 3 of 9.

                  Thanks

                  Comment


                    #10
                    RE: detecting non-numeric characters in a field

                    Cal: This is a good point, and one that I don't disagree with. In this case, I won't be doing math with the values in this field. But I do want the following: 1) to restrict the characters in the field to numerals, 2) to sort the values as if they are numbers, and 3) to allow the user to search the values in the field without entering leading zeros. I agree that all this can be done with numerals in a character field by 1)testing keyed or imported entries, 2)padding the values, and 3)creating an index that includes the str(val()) of the field's value. But in your experience, is this a case where breaking the "use character fields" rule would be appropriate in order to simplify the application? I am interested in your thoughts. Thanks,

                    -Bill

                    Comment


                      #11
                      RE: detecting non-numeric characters in a field

                      Stan: This function is great. I knew there was a way to do this with isalpha and substr, but I couldn't seem to simplify may code to something managable. The combination of FOR and LEN are great here. I tend to always use WHILE loops and forget about FOR, but that really makes for a concise function. Thanks again,

                      -Bill

                      Comment


                        #12
                        RE: detecting non-numeric characters in a field

                        Thanks to everyone. I want to experiment with CHKDIGIT too. I also don't do much with credit cards, etc. but this seems like a very useful tool.

                        -Bill

                        Comment


                          #13
                          RE: detecting non-numeric characters in a field

                          I learned it all from Ira, bless him.
                          There can be only one.

                          Comment


                            #14
                            RE: detecting non-numeric characters in a field

                            Bill,

                            First, I see any problem with breaking rules as long as we know the consequences and you seem to understand them quite well.

                            The reason I made that comment in the first place was the fact that the data originally had non-numeric characters. This implied to me that there might be some need for this again in the future -or- it might be a situation where leading zeros (or other char) might be needed. EX: I work with a company that uses 8 digit part numbers but all the ones I deal with only have 7 'real' digits and it creates problems if I fill in their forms and barcode labels without the leading zero.

                            The only other reason I can think of right now for maintaining a character field would be if there might be a need to search on certain characters in the field. EX: One of my database customers uses a 'master number' field that starts with the first two digits as the year the job was completed.

                            So, as I said above, I see no problem with using a numeric field since you understand the implications and are therefore making an informed decision.

                            Comment


                              #15
                              RE: detecting non-numeric characters in a field

                              Thanks for your input, Cal. I was anxious to discuss the reasons behind this particular "best practice," as I often pick up some ideas from such a discussion, even when a particular situation callls for breaking the "rules."
                              -Bill

                              Comment

                              Working...
                              X