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

Textseach function working properly?

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

    Textseach function working properly?

    I put this in the wrong forum, moving to Desktop Applications.

    I'm trying to do a very simple text search to see if a specific string exists within another string.

    I've tried textsearch it is always returning FALSE. Also, my example below using textsearch may seem backwards from the AlphaFive documentation, but if I code it according to the documentation I get an error "Cannot use function in this context" (search_in_string, find_string) as opposed to (find_string, search_in_string).

    Example:

    name = "Bugs Bunny"
    bool = textsearch("*Bunny*",name)

    bool is always FALSE.

    However the following code will return TRUE:

    name = "Bugs Bunny"
    bool = textsearch("*Bugs Bunny*",name)

    According to the documentation I should be able to find a substring within another string by using the "*" wildcard but it doesn't seem to be working....

    #2
    Re: Textseach function working properly?

    John,

    Have you tried using the following (taken from the Alpha Five V11 help file):

    Description

    The $ operator determines whether the character expression on the left of the operator is contained anywhere within the character expression on the right. Operations involving the $ operator return a logical result (i.e., TRUE or FALSE). The string comparison is not case sensitive.

    If Find_String is a null string ("") then this operator will return TRUE. While this seems a meaningless comparison, this can happen if your Find_String is stored in a variable and you neglect to test whether the variable string is empty before using this operator in an expression or script.

    Example:

    dim zzz as c = "Computer"


    ? "Comp" $ zzz


    I just tried the above example and it works fine for me...


    Using your example it needs to be edited a bit:

    ? textsearch("Bugs Bunny", "Bugs")
    = .T.


    or you could use:

    ? textsearch("Bugs Bunny", "Bugs AND Bunny")
    = .T.


    or another example taken from the help documentation:

    textsearch("now is the time for all good men", "time AND good") -> .T.

    The first string is the text to search and the second the search phrase or phrases. You do not use the "*" for wild card search instead you use AND or OR.

    PS these examples were carried out in the Code editor Interactive window that's why the ? is shown in front of some of the commands.
    Last edited by Alastair; 08-28-2013, 12:38 PM.

    Comment


      #3
      Re: Textseach function working properly?

      name = "Bugs*"


      ? textsearch("Bugs Bunny",name)
      = .T.


      name = "*ugs B*"

      ? textsearch("Bugs Bunny",name)
      = .T.
      There can be only one.

      Comment


        #4
        Re: Textseach function working properly?

        Thanks for the ideas...but I'm still very confused.

        1. What does the following mean (I see examples like this throughout the help documentation but have no idea what it is referring to):

        ? textsearch("Bugs Bunny",name)
        = .T.

        Is this some kind of monitor? This doesn't look like XBasic which I'm coding in.

        2. I don't see how the above example accomplishes what I'm trying to do. Doesn't textsearch("Bugs Bunny",name) look for the string Bugs inside of Bugs Bunny? I don't have a hard-coded string as the first parameter, I have a variable, and whenever I use a variable as the first parameter I get an error message that says "Cannot use function in this context".

        How would I code in XBasic, searching for the string "Bugs" inside a variable named VAR->NAME? textsearch(VAR->NAME, "Bugs") gets an error.

        Thanks again for the help! I've been a VB coder for over 20 years and having trouble getting up to speed with XBasic.

        Comment


          #5
          Re: Textseach function working properly?

          1. What does the following mean
          You can test expressions in the Interactive window. ? is shorthand for print/send results to window.


          How would I code in XBasic, searching for the string "Bugs" inside a variable named VAR->NAME?
          Don't know why textsearch() doesn't accept the variable as the search in string parameter but contains() and containsi() both seem to operate the way you want.

          name = "Bugs Bunny"

          ? CONTAINSI(name,"Bugs")
          = .T.

          ? CONTAINSI(name,"*ugs")
          = .T.

          ? CONTAINS(name,"Bugs")
          = .T.
          ? CONTAINS(name,"bugs")
          = .F.


          ? CONTAINS(name,"*ugs")
          = .T.

          ? CONTAINS(name,"*ugs b")
          =.F.
          There can be only one.

          Comment


            #6
            Re: Textseach function working properly?

            John,

            This should also work:

            dim name as c = "Bugs Bunny" 'this declares a string variable and assigns it the value "Bugs Bunny"

            ? "Bugs" $ name 'this line checks that the string (in this case "Bugs") exists in the variable name.

            = .T. 'this is the result

            If you were writing this in XBasic you wouldn't need the question mark, instead you would probably assign the result to another variable e.g.:

            dim name as C = "Bugs Bunny" 'declare variable and assign string
            dim result as L 'declare variable for result (L is a logical variable - will hold True/False)

            result = "Bugs" $ name 'carry out the check for the string and assign the result

            The question mark makes the code editor display the result, without it you wont see it. You can use it yourself go to the menu (you must be in the control panel view not running your database when you do this), select view, then Code editor (3rd option down) on Alpha Five V11 at least.

            It's quicker to demonstrate the code this way than it is for us to write the XBasic program and run it.

            One thing to remember when using the $ function, is it's not case sensitive, so:

            dim name as c = "Bugs Bunny"

            ? "bugs" $ name

            = .T.

            but,

            dim name as c = "Bugs Bunny"

            ? "zugs" $ name

            = .F.

            Hope this is clearer?
            Last edited by Alastair; 08-29-2013, 07:04 AM.

            Comment

            Working...
            X