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

Date Query filter

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

    Date Query filter

    I have spent more time on this than I should have to. I have toured the board, and played with this ad nauseum, and can't make it happen. I need help, please, to show me the error of my ways.

    I am simply (quite the joke) trying to filter the single table - Donations - by date range, through an xDialog that collects the start and end dates into variables, and using queryrun() to filter the table. I cannot get variables to work. Direct entries work through the Genie, but I can't get variables to run.

    The attached example has one table - 'donations'. The form F_donations has two, red buttons. One uses tries to use the character variables and the other converts them to date variables. Niether works.

    Any help is appreciated.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

    #2
    Re: Date Query filter

    Hi MIke,

    I think you are still recovering from your little holiday.;)

    I got the "date" version working by dimming the vdSdate and vdEdate variables as shared. I haven't worked through the code on the "C" type button yet. Work is interupting again, will have to get to it later if no one else has in the mean time.
    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: Date Query filter

      Tim,
      Yes, that must be my excuse. And working on things late into the night. Thank you for that rather simple solution that wasn't one of the 100 things I tried. Nothing further is needed. I just threw the Character path up for some degree of completeness. Don't bother (although I know you, as I, thrive on finding solutions!)

      Now, off to try and understand why the variables dimmed as local within one script didn't work and needed to be shared... The docs don't seem to tell me this should be necessary. Thanks again.
      Mike W
      __________________________
      "I rebel in at least small things to express to the world that I have not completely surrendered"

      Comment


        #4
        Re: Date Query filter

        Mike:
        A variable dimmed local will run at that script only. After the script runs, it goes to file 11.

        A shared variable is a session variable and is created when a layout window is first opened, or when an Operation is defined or run. You can use it between scripts running from the layout. More broad than local, less than global.
        Last edited by G Gabriel; 08-13-2007, 08:31 AM.

        Comment


          #5
          Re: Date Query filter

          Deleted. Accidental posting.
          Last edited by Mike Wilson; 08-13-2007, 07:15 PM.
          Mike W
          __________________________
          "I rebel in at least small things to express to the world that I have not completely surrendered"

          Comment


            #6
            Re: Date Query filter

            Originally posted by =G Gabriel View Post
            Mike:
            A variable dimmed local will run at that script only. After the script runs, it goes to file 11.
            Gabriel,
            Yes... so this is what the documentation suggests, too. Maybe you can offer a bit more wisdom for this dense sole. In the following code that has the variables vdSdate and vdEdate dimmed local (and does not work), which part of the code consitutes 'at that script only' and what defines the boundries of the code that delineate 'a script', such that the variable scoped local lies outside of the code that equals 'a script' and covered by scoping local?
            Code:
            	dim dbxDate as C
            	dim vtitle as C
            	
            	dim vcSdate as C="06/01/2007"
            	dim vcEdate as C="08/01/2007"
            	vTitle = "Dates"
            	
            	dbxDate=ui_dlg_box(vtitle,<<%dlg%
                        {lf};
            	{region}
            	Start Date:|[.16vcSDate];
            	End Date:|[.16vcEdate];
            	{lf};
            	{endregion};
            	{line=1,0};
            	{region}
            	<15OK!OK> <*15Cancel!CANCEL>
            	{endregion};
            	%dlg%)
                   SELECT
            	CASE dbxDate = "OK" [COLOR="Red"]
                       dim vdSdate as D
                       dim vdEdate as D
            	   vdSdate = ctod(vcSdate)
            	   vdEdate = ctod(vcEdate)[/COLOR]
            	
            	   DIM records_found as N
            	   records_found = topparent.queryrun("between(Do_date,Var->vdSdate,Var->vdEdate)","recno()","","No","",.f.)
            
            	CASE dbxDate = "Cancel"
            	   END
                   END SELECT
            Mike W
            __________________________
            "I rebel in at least small things to express to the world that I have not completely surrendered"

            Comment


              #7
              Re: Date Query filter

              Mike, I'll take a crack at it, subject to correction or clarification by those more knowledgeable than I.

              Code:
              topparent.queryrun("between(Do_date,Var->vdSdate,Var->vdEdate)","recno()","","No","",.f.)
              This code calls a method in the form, not a function in the currently running script. The method must be evaluated in the context of the form, and the form doesn't know about the local variables in the currently running script. Imagine doing this with two buttons. In button one you open the dialog and populate the local variables, vdSdate and vdEdate. Then that script ends. The dialog closes and the user is taken back to the form where she pushes the 2nd button. This button calls the queryrun() method of the form using the local vars from the first button. You wouldn't expect that to run, right? Well your script is doing the same thing. It's not passing variables to a function, it's trying to call a method of the form object using parameters the form itself can't evaluate.

              Comment


                #8
                Re: Date Query filter

                Tom:
                I'll take a crack at it, subject to correction or clarification by those more knowledgeable than I
                Don't hold your breath!

                Mike:
                I feel your pain. You reason that, since queryrun is part of that one script, then the local variables should, by definition, be available to queryrun. True. Except that this script opens an xdlg. When the user enters the values and those values are stored in the local variables, then you run the queryrun, in essence, you abandoned the "layout", that is the xdlg in which these variables were defined, and once that is closed, the variables goes away with it. Perhaps a better definition is:
                "..Variables of this sort are called local variables because they are restricted to the context in which they are defined"

                This makes me a bit curious if you would see the same behavior if you keep the xdlg open or make it modeless? I will have to investigate that.

                Anyway, I can't think of any good reason to dim a variable as local, except a couple. Maybe if I think hard enough, I might stumble at others. First reason is George Forman (a living proof that boxing causes brain damage or perhaps and more aptly in his case, brain damage causes one to box, which in turn causes brain damage).

                George Forman in his great wisdom, named all his five sons George. Thank goodness for an alert nurse who made sure to dim his sons as local variables, because if he dimmed them as shared, that household would be a major mess.

                What I am trying to say, you dim a variable local just for the mere chance that you might have dimmed other variables with the same name George in other areas.

                Second, if you have no plan to use them anywhere else, why clutter memory with useless variables.

                Comment


                  #9
                  Re: Date Query filter

                  Tim, Tom, Gabriel,

                  I appreciate your insights, I really do. I'm needing some time to digest this. I'm sensing I'm in a place a bit like Steve Hawkings trying to evaluate string theory to establish a unified theory to amalgomate relative physics.

                  I have broken this down to it's most "particle matter", and it still requires shared variables, holding a relational concept I haven't yet grasped. OK. I have to clearly ponder this more carefully.

                  I thank you all, sincerely!
                  Mike W
                  __________________________
                  "I rebel in at least small things to express to the world that I have not completely surrendered"

                  Comment


                    #10
                    Re: Date Query filter

                    another way to look at it is, you have a script (quryrun) within a script (xdlg).

                    Comment


                      #11
                      Re: Date Query filter

                      Originally posted by G Gabriel View Post
                      another way to look at it is, you have a script (quryrun) within a script (xdlg).
                      Technically in Mike's above (or below if you view newest messages at the top) code we have a script for the OnPush event that contains within it an xDialog and also the queryrun method. The query run code is not actually in the xdialog code. This doesn't really have a bearing on the scoping of the variables as far as the discussion has gone. It is rather just an observation.
                      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


                        #12
                        Re: Date Query filter

                        Thanks Tim..that's makes even easier to explain that those local variables were created in the context of the xdlg and cannot be shared with other scripts.

                        This begs the question, what if it were in the xdlg code?
                        I've got few questions to investigate and a little apetite to do so.
                        Last edited by G Gabriel; 08-14-2007, 10:01 AM.

                        Comment


                          #13
                          Re: Date Query filter

                          I did some testing and found out that whether the "second script" is run after the xdlg is closed vs if it is in the xdlg code it makes no difference. In both cases the variable is visible to that "second script".

                          Comment


                            #14
                            Re: Date Query filter

                            Let me see if I could explain this more intelligently, because I've done a lot of rambling that might cause more confusion than understanding.

                            1-The variables are dimmed as local in the context of a script that:
                            a-opens an xdlg, and then
                            b-runs queryrun

                            2-The variables, being local are visible throughout that script

                            The question becomes, if that is true, then how come queryrun gives an error message of bad filter, when the filter uses those variables?

                            I have run across this issue long time ago and learnt that to get it to work you need to either dim those variables as shared or global.

                            So, here is my explanation and it is purely speculative.
                            Yes, the variables are visible throughout the script, but when you invoke queryrun, which is a high level function, it opens the table to be queried, then it looks for the filter. In the context of the table opened by queryrun, those variables are not visible. It's a different context from the ones in which they were originaly dimmed.

                            To verify my theory, I used a different line of script instead of queryrun, just a message box after the OK button is clicked in the xdlg, and it shows the variable.

                            Comment

                            Working...
                            X