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

a function in browse filter fails

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

    a function in browse filter fails

    I have
    1) a table with a character field named: loginid
    2) a global variable as character named: vopenid
    3) a browse with a filter: loginid = var->vopenid
    The variable does not change while the browse is open. Between browse openings the variable does change and the browse does filter the table according the current value of the variable each time it opens.
    That works fine but the following does not work:
    Same table and same global variable
    4) a new function:
    FUNCTION getvopenid AS C ( )
    getvopenid = var->vopenid
    END FUNCTION
    Note that the function works fine in the interactive window.
    5) change the browse filter to: loginid = getvopenid()
    The browse no longer updates. The very first time the browse is opened it takes a long time to open. After that it opens quickly but the filter does not reflect the updated value of the variable.
    I need to use the function in the browse filter for other reasons but I have distilled the problem down to that one line function.
    Any help would be most welcome.
    Thanks
    Irwin

    #2
    Re: a function in browse filter fails

    Try
    Code:
    FUNCTION getvopenid AS C ( )
        dim global vopenid
        getvopenid = vopenid
    END FUNCTION
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

    Comment


      #3
      Re: a function in browse filter fails

      Thanks Tim, I tried the dim statement but it made no difference.
      Irwin

      Comment


        #4
        Re: a function in browse filter fails

        Irwin, is this a stand alone browse layout, or something you've embedded into a form? Is the layout based on a set of tables? Is the browse based on the primary table in that set?

        Perhaps more importantly, does your browse behave correctly if the filter uses the global variable instead of the function? Does it behave correctly if the filter uses a literal value instead of the global variable?

        Have you investigated the use of form.viewqueried() or browse.viewqueried() ?

        Comment


          #5
          Re: a function in browse filter fails

          Thanks Tom
          The browse is a stand alone.
          The layout is based on a single table
          The browse works fine if the filter uses the global variable instead of the function.
          And (good question Tom!) if the function uses a literal the same problem occurs. If the function is
          FUNCTION getvopenid AS C ( )
          getvopenid = "user1"
          END FUNCTION
          and the literal is changed to "user2" and the filter in the browse is loginid=getvopenid() the browse continues to filter on "user1" even after the literal is changed to "user2" and the browse is closed and reopened.
          So it has nothing to do with the global variable. The filter does not update if it includes a function.
          I have not tried browse.viewqueried(). I noticed the problem in an embedded browse but used a stand alone browse for these tests.
          They act the same.

          Comment


            #6
            Re: a function in browse filter fails

            I've stopped trying to embed a dynamic filter expression in my form layouts.

            Instead of embedding a dynamic filter expression in the layout and then simply opening the layout, I now leave the filter expression blank (in the properties of the layout), and open the form using a command that takes an optional filter argument.

            Comment


              #7
              Re: a function in browse filter fails

              Yes Tom, I tried exactly what you suggested. I put an event on a button that opens the browse. I took the filter out of the browse and put it in the event (used action scripting). The results are a little different but not good. Using the global variable in the filter works fine and returns instantly. Using the function in the filter now does filter correctly but takes thousands of times longer to return. For a table of only a few hundred records it takes 15 seconds to return when the function is in the filter in the event.

              FYI the xbasic from the action scripting in the event is (comments removed)

              Code:
              query.filter = "Loginid = getvopenid()"
              query.order = "recno()"
              DIM Shared varP_appt4wkcancel as P
              DIM layout_name as c 
              layout_name = "appt4wkcancel"
              dim tempP as p
              tempP=obj(":"+object_name_normalize(word(layout_name,1,"@")))
              if is_object(tempP) then 
              	if tempP.class() = "form" .or. tempP.class() = "browse" then 
              				dim flagIsBaseFilter as l 
              		flagIsBaseQuery = .t.		
              		if flagIsBaseFilter then 
              			tempP.BaseQueryRun(query.filter,query.order)
              		else
              			tempP.QueryRun(query.filter,query.order)		
              		end if 
              		tempP.activate()
              	else
              		varP_appt4wkcancel = :Browse.viewqueried(layout_name,query.filter, query.order )
              	end if
              else 
              	varP_appt4wkcancel = :Browse.viewqueried(layout_name,query.filter, query.order )
              end if
              Thanks
              Irwin

              Comment


                #8
                Re: a function in browse filter fails

                If it were me I'd run the function to get the search key, then I'd use the search key in the query filter passed to the statements that open the layout. If you have an index based on the loginid field lightning query optimization should speed things greatly.

                I would not embed the function in the filter passed to the statements that open the layout.
                Otherwise the function gets called and has to be re-evaluated for each record in the table.
                Last edited by Tom Cone Jr; 08-03-2010, 10:59 AM.

                Comment


                  #9
                  Re: a function in browse filter fails

                  Hey Tom, Bravo. That works great. I used action scripting to include inline xbasic:
                  dim shared thekey as c
                  thekey = getvopenid()

                  Then I used thekey as the filter:
                  Loginid = thekey

                  Works well and fast.
                  Thanks so much
                  Irwin

                  Comment

                  Working...
                  X