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

how do I create a large "IF" statement?

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

    how do I create a large "IF" statement?

    I have created a calculated field in my Flight Program for a small airline that I want to put a very large if statement into. There are about 30 conditions (flights)that I want it to check for, but it will only let me input 9 and then it chops off any text beyond that. I realize that I hit the limit, but I am sure that I should be able to create a script to accomodate my needs; so the questions are... how to I create this statement... where do I create it ...and how do I have my form reference or access it?

    I know there is a wise soul out there that knows what I need to do, so I await your kind and generous reply...

    Below, I have provided a shortened version of my IF statement to give you an idea of what I am trying to do.

    Thanks,

    Angie

    if(Depart_Flight="Grande Prairie".AND.Arrival="Fort Nelson".and.Dept_Time="Morning".AND.Day="Weekday",1,
    if(Depart_Flight="Grande Prairie".AND.Arrival="Fort St John".and.Dept_Time="Morning".AND.Day="Weekday",2,if(Depart_Flight="Grande Prairie".AND.Arrival="Calgary".and.Dept_Time="Morning".AND.Day="Weekday",3,
    if(Depart_Flight="Grande Prairie".AND.Arrival="Calgary".and.Dept_Time="Afternoon".AND.Day="Weekday",4,0))))

    Once I have established where the flight is going(i.e. 1, 2 3, etc, I will create the flight manifest based on the resulting number.

    #2
    RE: how do I create a large

    One way would be as follows:

    Rather than use a calculated field, use a layout variable.

    Then have a button that has Xbasic in it like:

    if this conditiion
    then this code
    else if this condition
    then this code
    else if this condition
    else
    etc etc
    end if

    then simply

    yourlayoutvar.value=result from above
    yourlayoutvar.refresh()

    Gary
    Gary S. Traub, Ph.D.

    Comment


      #3
      RE: how do I create a large

      Angie,

      You're tracking the components of a 'flight' instead of the flight. It's a bit like tracking the components of a car and then using the expression to figure out which car it is. Why not use another table where each record represents a flight ? -- tom

      Comment


        #4
        RE: how do I create a large

        Another thought would be to make a table with 5 fields
        Depart_flight
        Arrival
        Depart_time
        Day
        Desired_value
        The "1" "2" etc would be put in the desired_value field and you could have a lookupc function retrieve the value based on the 4 fields. The advantage would be not having to recode when something changes or gets added

        Of course this only works if the four fields are always the determining factors.

        Comment


          #5
          RE: how do I create a large

          Angie,

          I agree with Tom. Making a "Flight" table would probably be the most efficient way to handle this. A big plus is that if for any reason one of the filghts changes you just need to change the info in that record and not a large code.

          You could then use a lookup function to set your calc field.

          You might also want to take a look at the SELECT .. CASE function which I feel is better then the IF .. THEN in cases where you have many conditions.

          Scott

          Comment


            #6
            RE: how do I create a large

            Tom,I am not exactly clear on what you are saying. I am currently drawing all of my information from a Ticket that the agent fills out. Each ticket (passenger) represents a flight, however, they may have 2 or three stop overs between their departure and destination. Each leg of the flight by law, must have its own manifest, which means that a passenger may end up on three manifests. I need to ensure that they are on each manifest, otherwise overbooking may occur. Currently, all of the ticket info is placed in one table, which I then draw on for various other forms such as the manifest. Because the ticket agents select a Departure (FROM) for the passenger and a destination (TO)I want to re-use this info to generate the flight manifest for the pilots by grouping the stop overs and destinations by assigning a number to them through the if statement. The stop overs do not appear on their tickets so the if statement has got to be used to cover all of the possible combinations of stopovers. The manifest is generated by the if statement which I am using to filter the data so that only the passenger names for the tickets meeting the criteria are added to the manifest. I was trying to group the legs of the flights by assigning a number to the flights, and then by using the if statement to check for the number when generating the manifests, otherwise, I will have to have it check for the FROM and TO info, which is text, and is much more lengthy.

            So having said that, I am confused about exactly how youthink this should be approached. Failing that, where and how do I generate a large if statement? When I tried through the Scripting (Xbasic Editor) and checked my syntax, it gave me grief at the first line (Line 1 Column 1)stating that it was expecting a value. The code started as follows:
            if(Depart_Flight="Grande Prairie".AND.Arrival="Fort Nelson".and.Dept_Time="Morning".AND.Day="Weekday,1...etc...
            so for some reason it doesn't like the "If"...

            Any help would be appreciated...

            Thanks Again,

            Angie

            Comment


              #7
              RE: how do I create a large

              Angie

              What the others are trying to say is that you are using the tool(Alpha) improperly to solve your problem.

              Think of it like this. A hammer is actually two tools in one. It can pound a nail into position and remove that same nail, but with the opposite end of the head. Don't try to hammer the nail in with the claw, or remove a nail with the pounding surface.

              IMHO, your solution of using an if statement is using the wrong part of the tool. Rethink it and redesign using a more table driven solution. Alpha works well with data driven designs.
              Al Buchholz
              Bookwood Systems, LTD
              Weekly QReportBuilder Webinars Thursday 1 pm CST

              Occam's Razor - KISS
              Normalize till it hurts - De-normalize till it works.
              Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
              When we triage a problem it is much easier to read sample systems than to read a mind.
              "Make it as simple as possible, but not simpler."
              Albert Einstein

              http://www.iadn.com/images/media/iadn_member.png

              Comment


                #8
                RE: how do I create a large

                Angie,

                I suggest you identify the characteristics that make up a unique 'flight'. Presumably it would include:

                From
                To
                Carrier
                Time
                Day of week

                There may be other items which would have to be included if the 'collection' of items were to fully and uniquely describe a single 'flight'.

                If I were you, I'd build a table for 'Flight' records. Each 'Flight' would stand on its own, and would contain the fields just listed. This 'Flights' table could easily serve as a lookup source during data entry for customers, their tickets, and the flight manifest report you are working on.

                -- tom

                Comment


                  #9
                  RE: how do I create a large

                  Angie,

                  In addition to the words of wisdom provided in previous comments, to answer your original question of "how to create a very large IF statement" the simple answer is don't.

                  In situations where there are multiple conditions you are testing for, it's easier, simpler and more straightforward to accomplish the same using the SELECT...CASE statement.

                  eg: Your original "IF" statement is:
                  if(Depart_Flight="Grande Prairie".AND.Arrival="Fort Nelson".and.Dept_Time="Morning".AND.Day="Weekday",1,
                  if(Depart_Flight="Grande Prairie".AND.Arrival="Fort St John".and.Dept_Time="Morning".AND.Day="Weekday",2,if(Depart_Flight="Grande Prairie".AND.Arrival="Calgary".and.Dept_Time="Morning".AND.Day="Weekday",3,
                  if(Depart_Flight="Grande Prairie".AND.Arrival="Calgary".and.Dept_Time="Afternoon".AND.Day="Weekday",4,0))))

                  The same in a SELECT CASE statement is
                  SELECT
                  CASE Depart_Flight="Grande Prairie"
                  .AND.Arrival="Fort Nelson"
                  .and.Dept_Time="Morning"
                  .AND.Day="Weekday"
                  your_calc_field = 1
                  CASE Depart_Flight="Grande Prairie"
                  .AND.Arrival="Fort St John"
                  .and.Dept_Time="Morning"
                  .AND.Day="Weekday"
                  your_calc_field = 2
                  CASE Depart_Flight="GrandePrairie"
                  .AND.Arrival="Calgary"
                  .and.Dept_Time="Morning"
                  .AND.Day="Weekday"
                  your_calc_field = 3
                  CASE Depart_Flight="Grande Prairie"
                  .AND.Arrival="Calgary"
                  .and.Dept_Time="Afternoon"
                  .AND.Day="Weekday"
                  your_calc_field = 4
                  CASE ELSE
                  your_calc_field = 0
                  END SELECT

                  I think you will agree it's much more readable and easier

                  This is documented in the xbasic reference guide pg 799
                  There is also a CASE() statement on pg. 915, but the result is just the same as IF THEN

                  Comment


                    #10
                    RE: how do I create a large

                    Melvin,

                    thank you so much for replying and giving me an answer that makes sense to me...although I am trying to explore some of the alternative solutions offered, my understanding of Alpha5 is very limited... the previous solutions may make sense to those more experienced with Alpha5 but are somewhat vague for someone like myself who is not well versed with Alpha products. So again, thank you I appreciate the guidance.

                    Angie

                    Comment


                      #11
                      RE: how do I create a large

                      Angie,

                      You are more than welcome.

                      I also suggest you review the book
                      Access 97 Expert Solutions
                      by Stan Leszynski

                      although designed for Access 97, the concepts apply to
                      any database.

                      There is a large discussion on it in the announcements
                      forum.

                      Welcome to the world of Alpha Five :)
                      Melvin

                      Comment


                        #12
                        RE: how do I create a large

                        Hi Angie

                        What everyone above is really talking about is understanding database theory and design which will allow you to use the correct RDBMS tool.

                        Really, Really listen to what they are saying. Your approach is self limiting.

                        One of the key principals that trips people up when I teach database design is understanding the difference between Data and Information.

                        You first store your data properly, re. the above references to separate tables for flights. Once you have the right table/s structures and key values to store your data you can then create different views (ie. sets) which allows you to retrieve information from that data easliy.

                        Good Luck

                        Robert

                        Comment

                        Working...
                        X