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

Need help with IF() syntax

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

    Need help with IF() syntax

    I am having trouble nailing an IF statement selecting records for a report. The logic in English goes like this. If a license plate is photographed 3 times or more during a period AND it has been photographed and time stamped just once in the past 14 days, it should be selected for printing. If not, not.

    My original select statement was this:

    (Parking_Vio_Summary_History->Count_License_Plate>=3).AND.(Parking_Violation_History->Timestamp>=DATE()-14)

    That was giving me the vehicles that had 3 or more violations but the report would only print the violations that occurred in the past 14 days, not their entire violation history.

    So I started playing with the IF function:

    IF((Parking_Vio_Summary_History->Count_License_Plate>=3).AND.(Parking_Violation_History->Timestamp>=DATE()-14), Parking_Vio_Summary_History->Count_License_Plate>=3, Parking_Vio_Summary_History->Count_License_Plate>=3.AND.Parking_Violation_History->Timestamp>=DATE()-365)

    I think I have the condition fine. I just don�t know how to compose the true result and the false result. Obviously I want the true result to print and the false result to not print.

    #2
    Re: Need help with IF() syntax

    Mike,
    A bit of confusion here...The first part of the condition works fine as you have mentioned, but I am not certain about what you want the criteria to be in the second. As written here...
    AND it has been photographed and time stamped just once in the past 14 days,
    you would have to have a way to determine how many times it has been time stamped in the last 14 days. If you have such a calculated field, say called No_Timestamps that already had say a dbsum() or tablesum() that showed how many records had a timestamp, then something like--

    Code:
    (Parking_Vio_Summary_History->Count_License_Plate>=3) .AND. (No_Timestamps=1)
    If you didn't mean what you said, then try to say it again please...
    Last edited by MikeC; 11-14-2008, 05:30 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


      #3
      Re: Need help with IF() syntax

      Sorry for the confusion. My error.

      I have developed an A5 interface to an Autovu License Plate Recognition System. The statement actually should have said, "If there are one or more records of a violation, as determined by the existence of one or more Timestamps, in the past 14 days." I hope that clarifies.

      My original syntax in the select gave me all vehicle plates that had been photographed 3 or more times since the beginning of the system install AND would only select those records that also had a violation (Timestamp) in the past 14 days. Trouble is, on the letter to the violator it would only print records with Timestamps in the past 14 days and not the entire number of Timestamps (violations) since install.

      I tried to use the IF() function to get me where I need to be, but not skillful enough yet to pull it off.

      Thanks for the help,
      Mike

      Comment


        #4
        Re: Need help with IF() syntax

        Sorry Mike,

        I know I can do this but have a blank right now--could be the late time or my just not feeliing quite right tonight. I will come back to this tomorrow if noone else has come to your (my!) aid by then. A sample would be nice to work on but should actually be fairly straight-forward......
        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


          #5
          Re: Need help with IF() syntax

          In order to print everything if the existance of one or more, then you need to add another if statement:
          Something like:

          (Parking_Vio_Summary_History->Count_License_Plate>=3).AND. if((Parking_Violation_History->Timestamp>=DATE()-14), .t., .f. )

          Pat
          Pat Bremkamp
          MindKicks Consulting

          Comment


            #6
            Re: Need help with IF() syntax

            Thanks Pat!,

            I also think I saw the light as am a little more....well, lets say "alert" today! :)

            I came up with this and should work as well--

            Code:
            dim num as n
            dim flter as c
            flter="eval(between_date(\"Timestamp\",date()-14,date()))"
            num=tablecount("Parking_Violation_History",flter)
            
            if(num>=1,(Parking_Vio_Summary_History->Count_License_Plate>=3),.F.)
            'or maybe even if(num>=1,(Parking_Vio_Summary_History->Count_License_Plate>=3),[COLOR="Red"]""[/COLOR])
            Your filter would then be equal to the if statement.
            Last edited by MikeC; 11-15-2008, 12:14 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


              #7
              Re: Need help with IF() syntax

              Thanks a bunch.

              Comment


                #8
                Re: Need help with IF() syntax

                I thought I had enough help and direction to put this as the select record filter and have it work, but it keeps giving me an invalid expression message.

                IF(tablecount("Parking_Violation_History",eval(between_date(\ "Parking_Violation
                _History->Timestamp\ ",Date()-14,Date())))>=1,Parking_Vio_Summary_History->
                Count_License_Plate>=3,.f.)

                I saved the last message as both xbasic code and a function, but I don't know how to call it before printing the report.

                Thanks,
                Mike

                Comment


                  #9
                  Re: Need help with IF() syntax

                  Mike,
                  Present a sample and am sure I or someone can figure out the correct syntax--much easier to do such things hands on---I could guess....and guess....and guess again though-- I guess!!! :)

                  One more blind attempt by me---I really should work on these types things later on in the am....like after maybe 6 hours of sleep! I may have to use a tablemax, occurs, or something of the like, but will wait for others or a sample before going further.

                  Code:
                  dim num as n
                  dim flter as c
                  flter="eval(between_date(\"Timestamp\",date()-14,date()))"
                  num=tablecount("Parking_Violation_History",flter)
                  
                  Your_Filter="num>=1 .AND. (Parking_Vio_Summary_History->Count_License_Plate>=3)"
                  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


                    #10
                    Re: Need help with IF() syntax

                    Here is a sample of the database and my report. The more I think about what I am trying to do, apply a filter to do my record selection, but ignore my filter to print all the Timestamps (violations) relative to the records. It may just be impossible to do.

                    Mike

                    Comment


                      #11
                      Re: Need help with IF() syntax

                      Mike,
                      I think I have it but please give me an example of a date period and what specific records should come up--even more than one example would be great--but out of time for a few now, but will check back when I can. I set it up to check back 44 days and got one record for Barnhart circle, 2 records for Orrington circle.........
                      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


                        #12
                        Re: Need help with IF() syntax

                        The logic is the same, but you may want to change DATE()-14 to DATE()-30 so you will be sure to grab more records. A quick look at the Violations History table shows that 11 Acero Court looks like a good prospect. They have a car with plate 5LIY827 that first violated on 8/28/08 and last violated on 11/3/08.

                        If the selection is working properly, license_count>=3 and DATE()-30. should make it qualify. Then look at the letter and see that ALL violations are printed going back to the first on 8/28/08.

                        Thanks,
                        Mike

                        Comment


                          #13
                          Re: Need help with IF() syntax

                          I had all sorts of issues in my dialogs doing this. Here are some commands that I use that may help you.


                          Peter

                          Code:
                          dim filename   as c
                          dim exportfile as c
                          dim DropDownBox1 as c
                          
                          'dim Client_Code as c
                          'dim Date_Type as c
                          'dim To_Date as d
                          'dim From_Date as d
                          'dim Export_Order as c
                          
                          	exportfile = Client_Code + " Release by" + " Date_Type " + time("dd-MM-yyyy", now(.t.)+ 36000) + ".xls"
                          	filename = session.session_folder + exportfile
                          	dim a_tbl as p
                          	a_tbl = table.open("<ADB_Path>\releases")
                          	
                          	
                            if Date_Type = "Actual Shipped Date" then
                          
                                if Export_Order = "Release" then 
                          			query.order = "release"
                          	  end if 
                          
                                if Export_Order = "Date" then 
                          			query.order = "Date_Order_Dispatched"
                          	  end if 
                          
                          		query.Filter =  "Client_id= \""+Client_Code + chr(34) + " .and. between(Date_Order_Dispatched,ctod(\""+From_Date+"\"),ctod(\""+To_Date+"\"))"
                            end if
                            
                            
                            if Date_Type = "Release Date" then
                            	
                            	  if Export_Order = "Release" then 
                          			query.order = "release"
                          	  end if 
                          
                                if Export_Order = "Date" then 
                          			query.order = "Date_Order_Received"
                          	  end if 
                          
                          		query.Filter =  "Client_id= \""+Client_Code + chr(34) + " .and. between(Date_Order_Received,ctod(\""+From_Date+"\"),ctod(\""+To_Date+"\"))"
                            end if
                          Insanity: doing the same thing over and over again and expecting different results.
                          Albert Einstein, (attributed)
                          US (German-born) physicist (1879 - 1955)

                          Comment

                          Working...
                          X