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

CONTAINS() fails to recognize more than one "find" word

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

    #16
    Re: CONTAINS() fails to recognize more than one "find" word

    All,

    Thanks for your suggestions/insights. I have almost replicated the functionality of Microsoft Outlook's Contact name parsing, but now notice a small glitch in Alpha's word() function.

    Why does Alpha drop the period in a string? I would think that words would be separated by spaces only.

    Code:
    Henry A. Apple, Sr., PhD parses to 
    First name: Henry
    Middle name: A.
    Last name; Apple
    Pedigree: Sr
    Degree: PhD
    
    The pedigree should be Sr. not Sr
    Code:
    P. T. Barnum parses to 
    First name: P
    Middle name: T.
    Last name: Barnum
    
    The first name should be P. not P
    The reason why the . period appears correctly in the middle name is that the middle name is the residual string.

    Alpha is having difficulty getting the period right anytime the word() function is used.

    Code:
    mString = ""
    mFirst_Name = ""
    mMiddle_Name = ""
    mLast_Name = ""
    mPedigree = ""
    mDegree = ""
    
    mString = topparent.full_name
    mDegree = word(mString,-1,",")
    mString = word(mString,1,",")
    IF CONTAINS(mString, "Jr.") .OR. CONTAINS(mString, "Sr.") .OR. CONTAINS(mString, "III") .OR. CONTAINS(mString, "IV")
    	mPedigree = word(mString,-1)
    	msgbox(mPedigree)
    	mString = word_subtract(mString,mPedigree)		
    END IF
    
    mString = word_subtract(mString,mPedigree)
    mLast_Name = word(mString,-1)
    mString = word_subtract(mString, mLast_name)
    mFirst_Name = word(mString,1)
    mString = word_subtract(mString, mFirst_Name)
    mMiddle_Name = mString
    
    IF mdegree = topparent.full_name
      mdegree = ""
    END IF
    
    parentform:First_Name.value = mFirst_Name
    parentform:Middle_Name.value = mMiddle_Name
    parentform:Last_Name.value = mLast_Name
    parentform:Name_Pedigree.value = mPedigree
    parentform:Name_Degree.value = ltrim(mDegree)
    A sample database of names with a form with a button to perform parsing is attached.

    Bob McGaffic
    Pittsburgh, PA
    Last edited by rmcgaffic; 05-01-2009, 01:46 PM.

    Comment


      #17
      Re: CONTAINS() fails to recognize more than one "find" word

      Hi Bob,
      No sample is attached....but even so, and not saying it should matter, but have you tried to explicitly tell the word() function to use a space as the delimiter using the third argument??
      Mike
      __________________________________________
      It is only when we forget all our learning that we begin to know.
      It's not what you look at that matters, it's what you see.
      Henry David Thoreau
      __________________________________________



      Comment


        #18
        Re: CONTAINS() fails to recognize more than one "find" word

        WORD() seems to work as expected

        If you have a structure like WORD(text,n) then the period is considered punctuation and is always stripped off.

        MikeC is correct. If you have a structure like WORD(text,n," ") then the period is retained as part of the word. In this case you need to remove trailing commas( some words returned in the above example are "Apple," and "Sr.,").

        Comment


          #19
          Re: CONTAINS() fails to recognize more than one "find" word

          Mike,

          Sorry about that omission. I just appended the database to my previous message.

          The documentation for word() states that the word delimiter is
          Code:
          Optional. Default = space (" ").
          I have tried to selective insert the word delimiter but the results are not stable. It fixes one problem but creates another.

          NOT OK
          For example:
          Changing
          mPedigree = word(mString,-1)
          to
          mPedigree = word(mString, -1, " ") still does not return in the proper pedigree

          Henry A. Apple Sr., Phd returns
          return Sr as the pedigree, not Sr.

          OK
          Yet changing
          mFirst_Name = word(mString, 1)
          to
          mFirst_Name = world(mString, 1, " ") does return the correct first name, as for example

          P. T. Barnum returns
          the first name of P. and not just P as previously.

          So my question remains why is the use of the default word delimiter either explicitly or implicitly not behaving correctly?

          'Tis a puzzlement!

          Bob McGaffic
          Pittsburgh, PA
          Last edited by rmcgaffic; 05-01-2009, 02:45 PM.

          Comment


            #20
            Re: CONTAINS() fails to recognize more than one "find" word

            Bob,

            You should resubmit your code because pedigree comes out as "Sr." for me when using WORD(mString,-1," ").

            Comment


              #21
              Re: CONTAINS() fails to recognize more than one "find" word

              Works here as well (except still need to parse the comma).
              Code:
              mString="Henry A. Apple Sr., Phd" 
              mPedigree = word(mString, -2, " ")
              ?mPedigree
              = "Sr.,"
              Bob, I do agree that if the default is truly a space then it should not have to be explicitly used as the 3rd argument.....but then this is not the only function that has a small quirk---seem to remember that although .enter_end() defaults to .T. for whether or not to save the record, many here use .enter_end(.T.) as it does seem that occasionally it does not save. I try not to rely upon a default when it can be easily added explicitly.

              So either you can submit as a bug/issue of the function or submit as an issue with the documentation....don't know how Alpha will see it as.
              Last edited by MikeC; 05-01-2009, 03:18 PM.
              Mike
              __________________________________________
              It is only when we forget all our learning that we begin to know.
              It's not what you look at that matters, it's what you see.
              Henry David Thoreau
              __________________________________________



              Comment


                #22
                Re: CONTAINS() fails to recognize more than one "find" word

                Attached is my code with the word delimiter inserted.

                OK
                Henry A. Apple Sr., PhD
                returns pedigree Sr. rather than Sr

                NOT OK
                William Hignett Jr.
                returns pedigree Jr rather than Jr.

                Bob McGaffic
                Pittsburgh, PA

                Comment


                  #23
                  Re: CONTAINS() fails to recognize more than one "find" word

                  Hi Bob,
                  I guess I will have to go on my v9 computer to verify as it still turns out correctly on v8 (the word() function has not changed between versions but guess could be something in v9 changes how it is used).
                  I get
                  Code:
                  mString="William Hignett Jr."
                  mPedigree = word(mString, -1, " ")
                  ?mPedigree
                  = "Jr."
                  with v8

                  I will confirm now with v9 in a bit.


                  EDIT: Just confirmed--is correct in v9 as well.
                  Last edited by MikeC; 05-01-2009, 03:29 PM. Reason: confirmation
                  Mike
                  __________________________________________
                  It is only when we forget all our learning that we begin to know.
                  It's not what you look at that matters, it's what you see.
                  Henry David Thoreau
                  __________________________________________



                  Comment


                    #24
                    Re: CONTAINS() fails to recognize more than one "find" word

                    Bob,
                    You didn't change your button script to explicitly use " " as the delimiter. Once this is done Sr. comes out as expected.... Jr does not as you are not accounting for when there is No comma to parse it out for your if/then condition. If you add the comma to after Jr. the message comes up with the correct parsing. You need a few more if/thens I think to accommodate all scenarios.....
                    Mike
                    __________________________________________
                    It is only when we forget all our learning that we begin to know.
                    It's not what you look at that matters, it's what you see.
                    Henry David Thoreau
                    __________________________________________



                    Comment


                      #25
                      Re: CONTAINS() fails to recognize more than one "find" word

                      Mike,

                      I agree with you. When I do this interactively in V9, everything is OK

                      William Hignett Jr.
                      correctly returns Jr. as the pedigree.

                      However, when I execute my button's program
                      William Hignett Jr.
                      INCORRECTLY returns Jr as the pedigree

                      The code is as follows:
                      IF CONTAINS (mString,"Jr.")
                      mPedigree = word(mString, -1, " ")
                      mString = word_subtract(mString, mPedigree)
                      END IF

                      Any suggestions why this works interactively and not when the above code is executed?

                      Bob McGaffic
                      Pittsburgh, PA

                      Comment


                        #26
                        Re: CONTAINS() fails to recognize more than one "find" word

                        Bob,
                        Not getting that at all, but did notice you will need to use alltrim()....and do need to add more if/then as Jr. will not ever be included as there is No comma in the name. When I account for the nonexistent comma (test the string for Jr. using space as delimiter) and use Alltrim() I get the appropriate messagebox message Jr.
                        Mike
                        __________________________________________
                        It is only when we forget all our learning that we begin to know.
                        It's not what you look at that matters, it's what you see.
                        Henry David Thoreau
                        __________________________________________



                        Comment


                          #27
                          Re: CONTAINS() fails to recognize more than one "find" word

                          Bob,

                          Make these mods to the WORD() lines and add the TRIM() line.The mPedigree=word(mstring,-1," ") didn't work because it matched trailing spaces which were not removed since mString=word(mString,1,",") returns the entire string with blanks when there is no ",".

                          Code:
                          mString = topparent.full_name
                          mDegree = word(mString,-1,",")
                          mString = word(mString,1,",")
                          mstring=trim(mstring)
                          IF CONTAINS(mString, "Jr.") .OR. CONTAINS(mString, "Sr.") .OR. CONTAINS(mString, "III") .OR. CONTAINS(mString, "IV") then
                          	mPedigree = word(mString,-1," ")
                          	msgbox(mPedigree)
                          	mString = word_subtract(mString,mPedigree)
                          END IF
                          
                          mString = word_subtract(mString,mPedigree)
                          mLast_Name = word(mString,-1," ")
                          mString = word_subtract(mString, mLast_name)
                          mFirst_Name = word(mString,1," ")
                          mString = word_subtract(mString, mFirst_Name)
                          mMiddle_Name = mString
                          
                          IF mdegree = topparent.full_name
                            mdegree = ""
                          END IF
                          
                          parentform:First_Name.value = mFirst_Name
                          parentform:Middle_Name.value = mMiddle_Name
                          parentform:Last_Name.value = mLast_Name
                          parentform:Name_Pedigree.value = mPedigree
                          parentform:Name_Degree.value = ltrim(mDegree)
                          Last edited by aRob; 05-01-2009, 04:37 PM. Reason: extra lines

                          Comment


                            #28
                            Re: CONTAINS() fails to recognize more than one "find" word

                            Works for me.

                            Bob, are you making it so that Sr. , Jr. , etc. have to be entered with an uppercase first letter---if not then suggest using Containsi() instead of Contains().
                            Mike
                            __________________________________________
                            It is only when we forget all our learning that we begin to know.
                            It's not what you look at that matters, it's what you see.
                            Henry David Thoreau
                            __________________________________________



                            Comment


                              #29
                              Re: CONTAINS() fails to recognize more than one "find" word

                              All,

                              The revisions suggested by Rob worked perfectly.

                              I really appreciate all of your comments.

                              Frankly, I feel a little like I re-invented the wheel here. This is the kind of commonly used, plug and play code that I would hope Alpha would offer in its demos or examples or books.

                              Hopefully, I will have time to annotate this code and add it to the code library this weekend. I can't imagine I'm the only one who wants to make data entry easy by allowing a user to enter a name and behind the scenes to parse it for sorting and other purposes.

                              Thank you again,

                              Bob McGaffic
                              Pittsburgh, PA
                              Last edited by rmcgaffic; 05-01-2009, 07:55 PM.

                              Comment


                                #30
                                Re: CONTAINS() fails to recognize more than one "find" word

                                Bob,

                                You probably will want to TRIM() the results of all your WORD_SUBTRACT() functions otherwise you will have more problems if you accidentally have 2 spaces between words instead of only one.

                                ie. mString = TRIM(word_subtract(mString,mPedigree))

                                Comment

                                Working...
                                X