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

$ (Substring Inclusion Operator)

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

    $ (Substring Inclusion Operator)

    Hello all,

    I am unable to get the $ to work properly. I am not getting any errors but I am getting all records returned in my embedded browse. I have attached a sample db in case you need it.

    I have two fields in my 'lookup' table, both character fields ... I prefer my 2nd field to be a memo field but thought that maybe that was my problem. I changed to character and still cannot get it to work.

    When the form is loaded you are prompted for text to search on. The text you input is placed in a global variable vcgICD9Text. The online help shows use of the $ this way:

    "Computer" $ Company

    "Computer" being the search text and Company being the field name

    In my case I am using the variable in place of the search text so my filter theoretically should look like this:

    query.filter = vcgICD9Text $ DESC

    DESC being my field name.

    At the end of the message are the different query.filter that I tried with the results I received. Tested all of them with my DESC field as memo and as character. The attached zip currently has DESC as a character field.

    Since I am not getting any errors, this leads me to think that it is the query.filter line that I am trying is not reading the value of my variable and comparing it to the DESC field data.

    The xdialog and script below are both in the OnInit event of the lookup form. What am I doing wrong?

    Thanks
    Cheryl


    ========================

    dim tbl as P
    dim qry as P
    dim nrecs as N

    tbl = table.current()
    query.description = "Search"
    query.order = "code"
    'query.filter = var-"vcgICD9Text $ DESC ' this returns an error that the variable DESC is not found
    'query.filter = vcgICD9Text $ "lookup-"DESC" ' this does not return an error but returns all records
    'query.filter = var-"vcgICD9Text $ "lookup-"DESC" ' no error, but all records returned
    'query.filter = (vcgICD9Text $ "lookup-"DESC") ' no error, but all records returned
    'query.filter = vcgICD9Text $ "DESC" ' no error, returns all records
    'query.filter = var-"vcgICD9Text $ lookup-"DESC ' no error, returns all records


    query.filter = var-"vcgICD9Text $ (lookup-"DESC) ' no error, returns all records
    query.options = ""
    qry = tbl.query_create()

    nrecs = qry.records_get()
    IF (nrecs = 0) then
    qry.drop()
    ui_msg_box("Null Query","There are no records in the Query" ,UI_INFORMATION_SYMBOL)
    END
    end if
    Cheryl
    #1 Designs By Pagecrazy
    http://pagecrazy.com/

    #2
    RE: $ (Substring Inclusion Operator)

    query.filter = "atc('" + vcgICD9Text + "',DESC) > 0"
    query.filter = "\"" + vcgICD9Text + "\"$DESC"

    Either method works.

    The issue is that you have to send a string to the query. If the value in the variable is "ch" then what you want to send to the query is "ch"$DESC.
    That includes the quote marks. To do that, you need to send the first quote, "\"" (the backslash is an Escape character that tells A5 to take the next character literally) then add the result of the variable, then add another quote plus the $DESC. The \" can also be replaced with a single quote but it is often harder to read - "'".

    The AT() and ATC() functions return the location of the string rather than just a T/F answer. The ATC() function is not case sensitive.

    When the variable is global, query.filter = "var->vcgICD9Text$DESC" also works.

    Cal Locklin
    www.aimsdc.net

    Comment


      #3
      RE: $ (Substring Inclusion Operator)

      Cal,

      I can't thank you enough. I will not admit to how many hours I have spent on trying to search the memo field and get the proper results. It is always in my syntax which I have lost a lot of hair over.

      Thanks again, all three return the results I am looking for!

      Cheryl
      Cheryl
      #1 Designs By Pagecrazy
      http://pagecrazy.com/

      Comment


        #4
        RE: $ (Substring Inclusion Operator)

        Hi Everyone,

        Long time no see. I am back with experiencing this same problem in a different application. I have my code in the OnPush event of a button. I do not receive any errors but 'all' records are being returned and my filter is being ignored. Has something changed that I might be missing? I have tried three different versions of the filter.

        I run a lookup script to populate the global variable vcgSubCode, I then run the query script to filter my records and then load the form. If the sub category code entered in the lookup does not exist, I get the error message correctly. If the sub category code does exist, I get all records returned when the form loads instead of only the records that match the sub category code.

        Thanks
        Cheryl

        '***** Query table and return matching records *****

        dim tbl as P
        dim qry as P
        dim nrecs as N

        tbl = table.open("prodsubcat")

        query.description = "Search"
        query.order = "sub_code"
        query.filter = "\"" + vcgSubCode + "\"$SUB_CODE" 'value of vcgSubCode comes from lookup_sub_code script
        'query.filter = quote(vcgSubCode) + "$sub_code"
        'query.filter = "var-"vcgSubCode$sub_code"
        query.options = ""
        qry = tbl.query_create()

        nrecs = qry.records_get()
        IF (nrecs = 0) then
        qry.drop()
        ui_msg_box("Null Query","There are no matching records in this search, please try again" ,UI_INFORMATION_SYMBOL)
        END
        end if

        xbasic_wait_for_idle()
        tbl.close()
        end
        Cheryl
        #1 Designs By Pagecrazy
        http://pagecrazy.com/

        Comment


          #5
          RE: $ (Substring Inclusion Operator)

          Hi Cheryl,

          Is the form based on the same table as the query?
          Is the form set to display currently selected records?

          -- tom

          Comment


            #6
            RE: $ (Substring Inclusion Operator)

            Hi Tom,

            The form is based on the same table as the query. After the query is run I have the following to load the form:

            'run custom script to query table for matching records
            script_play("query_item_code")

            xbasic_wait_for_idle()

            '==========================================================

            dim shared oktosave as L 'this var used by CanSave event later on
            'form will save current changes only when this
            'variable is true. It gets set to true when
            'the user pushes the SaveChanges button. This
            'is the only way to save the changes.
            oktosave = .f.

            '==========================================================

            'Load Add/Edit form
            frm = form.load("prod_items")
            'lock down the called form
            frm.restrict_browse = .t.
            frm.restrict_change = .F. 'permit changes only
            frm.restrict_continuous_enters = .t.
            frm.restrict_delete = .t.
            frm.restrict_edit = .t.
            frm.restrict_enter = .t.
            frm.restrict_find = .t.
            frm.restrict_index = .t.
            frm.restrict_locate = .t.
            frm.restrict_navigation = .t.
            frm.restrict_query = .t.
            frm.restrict_range = .t.

            '==========================================================

            'Placing the code here instead of the form event
            'minimizes the form load flickering

            'hide cancel and save buttons on init
            frm:cancelchanges.hide()
            frm:savechanges.hide()

            frm:text2.text = "View Only"
            frm:text2.refresh()

            '==========================================================

            frm.resynch()
            frm.show()
            frm.activate()
            'Activate object editrecord button in current form.
            frm:editrecord.activate()
            this.enable() 'enable button on the way out
            end


            Does that help any?
            Thanks
            Cheryl
            Cheryl
            #1 Designs By Pagecrazy
            http://pagecrazy.com/

            Comment


              #7
              RE: $ (Substring Inclusion Operator)

              It might be illuminating to put a line in after

              query.filter = "\"" + vcgSubCode + "\"$SUB_CODE" 'value of vcgSubCode comes from lookup_sub_code script

              like

              ui_msg_box("Testing","Filter is now "+query.filter)

              and see if you see what you expect to see. You could also use the debugger to view the contents of the query.filter variable.
              There can be only one.

              Comment


                #8
                RE: $ (Substring Inclusion Operator)

                Hi Stan,

                I did as suggested and attached the results. The variable value is correct, but it is quoting the $SUB_CODE which I believe is the reason I am getting all records?

                Thanks
                Cheryl
                Cheryl
                #1 Designs By Pagecrazy
                http://pagecrazy.com/

                Comment


                  #9
                  RE: $ (Substring Inclusion Operator)

                  Cheryl,

                  I prefer putting a space on either side of the substring inclusion operator.

                  It's also important to force the query list to be rebuilt each time. Your script leaves the query.options term empty.

                  Using the customer table in AlphaSports I worked up this example in the interactive editor for you.

                  Code:
                  tbl = table.open("Customer")
                  query.order = "LastName"
                  query.options = "M"
                  vcSubLname = "ab"
                  query.filter = "\"" + vcSubLname + "\" $ LastName"
                  ix = tbl.query_create()
                  ?tbl.lastname
                  = "Abrams              "
                  
                  tbl.fetch_last()
                  
                  ?tbl.lastName
                  = "Peabody             "
                  
                  ?ix.records_get()
                  = 3
                  This query returns 3 records where the LastName field includes the string "ab". Hope this helps.

                  -- tom

                  Comment


                    #10
                    RE: $ (Substring Inclusion Operator)

                    Thanks Tom, but no cigar. There is obviously something wrong somewhere but I am too tired to deal with it at this point. I will play around with it another time and report back when I am able to get it working. Thanks everyone for your assistance.

                    Cheryl
                    Cheryl
                    #1 Designs By Pagecrazy
                    http://pagecrazy.com/

                    Comment


                      #11
                      RE: $ (Substring Inclusion Operator)

                      Cheryl:
                      Hope your trip to the moon was enjoyable!
                      It seems that you brought a little souvenier back with you, the "$", thanks !

                      ""There is obviously something wrong somewhere""
                      Yes,........ it's the filter:

                      ""'query.filter = quote(vcgSubCode) + "$sub_code" ""

                      Should be:
                      query.filter = "quote(vcgSubCode) + '$sub_code' = .t. "

                      Gabe
                      One caveat: I am not sure if quote() will double or single quote the the variable. I havn't tested it. If it double-quote it, you have to add another line to evaluate the variable first.

                      Comment


                        #12
                        RE: $ (Substring Inclusion Operator)

                        query.filter = "quote(vcgSubCode,"'") + '$sub_code' = .t. "
                        Gabe

                        Comment


                          #13
                          RE: $ (Substring Inclusion Operator)

                          Hi Gabe,

                          Thanks for your attempt, but the filter you were correcting is not the filter I was using as you can see I have it commented out in the code.

                          Cheryl

                          I have resolved the issue. The problem was not with my code or my filter. I am using this exact code in another application without error, just different table/field names.

                          I had to go through the application that was working one step at a time and compare it with my current application to determine which step was different.

                          The problem was with the form I was loading in the current application. I had an order expression set in the filter/order of the form properties which was causing a conflict with the query.filter. Once I removed this order expression I am getting the proper results returned.

                          Thanks all for your help. Hopefully this will help somebody else in the future. It is not always the code that is wrong, it could very easily be something else in the process that is causing a conflict along the line.

                          Had I included a copy of my application with my post, somebody else may have noticed this more quickly for me. Further proof that more detailed information should be included in our posts when requesting assistance.

                          Cheryl
                          Cheryl
                          #1 Designs By Pagecrazy
                          http://pagecrazy.com/

                          Comment


                            #14
                            In v7, the !$ (does not contain) operator has been added. Instead of writing:

                            Code:
                            if .not. "foo" $ "foobar"
                            ...
                            end if
                            you can now write:

                            Code:
                            if "foo" !$ "foobar"
                            ...
                            end if
                            Aaron Brown
                            Alpha Software Development Team

                            Comment


                              #15
                              Cheryl, please e-mail me : [email protected]
                              If you have the time, I would like to briefly discuss how you use the
                              'save changes' routine you have described on your buttons.
                              I understand you are very busy, so whenever you have time
                              thanx
                              D

                              Comment

                              Working...
                              X