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

Proper use of 'Case'

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

  • Proper use of 'Case'

    Not sure if I'm using the case function properly but this is what I have:

    CASE(isnotblank(t_form_dates->CAF_Date1), Name+" signed a form dated "+t_form_dates->CAF_Date1+" acknowledging all "+Category+" must be reported.",.t.)

    When working properly, it should read:

    John signed a form dated 1/12/10 acknowledging all income must be reported.

    The values of the Name, CAF_Date1 and Category fields are chosen by the user.

    Thanks for the suggestions!

    kenn
    TYVM :) kenn

    Knowing what you can achieve will not become reality until you imagine and explore.

  • #2
    Re: Proper use of 'Case'

    Almost.

    Isnotblank() requires that the field name be quoted and you're missing the return value for the .t. section.

    Code:
    CASE(isnotblank([COLOR="red"]"[/COLOR]t_form_dates->CAF_Date1[COLOR="red"]"[/COLOR]), Name+" signed a form dated "+t_form_dates->CAF_Date1+" acknowledging all "+Category+" must be reported.",.t.[COLOR="Red"],""[/COLOR])
    I've never used isnotblank() supplying the field name with the tablename-> syntax so I'm not sure how that will work.

    Code:
    testcaf_date1 = {01/01/2010}
    name = "Ken Nordin"
    category = "malfeasance"
    
    ? CASE(isnotblank("var->testcaf_date1"), Name+" signed a form dated "+testcaf_date1+" acknowledging all "+Category+" must be reported.",.t.,"")
    = "Ken Nordin signed a form dated 01/01/2010 acknowledging all malfeasance must be reported."
    There can be only one.

    Comment


    • #3
      Re: Proper use of 'Case'

      You have two conditions but only one value. Every condition listed in a CASE() statement must have a value to follow:

      CASE(isnotblank(t_form_dates->CAF_Date1), Name+" signed a form dated "+t_form_dates->CAF_Date1+" acknowledging all "+Category+" must be reported.",.t.,"")

      Steve

      Comment


      • #4
        Re: Proper use of 'Case'

        An IF() statement is more appropriate here. You are only testing for one condition.
        And rather than isnotblank() use isblank() or better off ="" and reverse the true/false arguments, i.e.:
        if(field="","",...the other statement..)

        Comment


        • #5
          Re: Proper use of 'Case'

          Thanks for the quick replies.

          Stan: The table name was used because the field is in a child table, Alpha automaticly included the table name.

          Steve: I tried adding ,"" but no go.

          Gabe: I'm using the case statement here because once this part is working, I will be adding other parts as explained below.

          The idea is to simplify as much as possible and the user fills in only the fields and while the form will contain other fields, these 3 are for this part of the report. These are the fields and values where the bottle neck is:

          Forms: CAF; HRF; CRF; MED
          Categories: Income; Assets, Persons

          It is possible for a person to have completed more than one form and it could effect more than one Category. The best way I've thought of to create this is with a calculated field. The end result would be for the sentence to read something like:

          John signed CAF forms dated 1/12/09 acknowledging all income must be reported.

          If the issue is assets instead of income, then the sentence would read the same except the word 'assets' would be used instead of 'income'.

          To add to the mess, both income and assets could be a factor so I would need to have one sentence for each or a sentence that would read something like:

          John signed CAF forms dated 1/12/09 acknowledging all income and assets must be reported.

          OK, to complicate things a bit more, it is possible to use multi[ple forms and categories so....

          John signed CAF forms, HRF forms and CRFforms dated 1/12/09, 2/12/09 and 4/1/09 acknowledging all income and assets must be reported.

          I'm trying to start 'small with this and get it working a little at a time.

          Thank you for your help.

          kenn
          TYVM :) kenn

          Knowing what you can achieve will not become reality until you imagine and explore.

          Comment


          • #6
            Re: Proper use of 'Case'

            It'll be a lot easier to answer questions and provide solutions if you attach a small sample set here with a few dummy records. Steve's solution should work with the addition of the quotes around the field name in the isnotblank() - actually the same thing I suggested.
            There can be only one.

            Comment


            • #7
              Re: Proper use of 'Case'

              Originally posted by Stan Mathews View Post
              It'll be a lot easier to answer questions and provide solutions if you attach a small sample set here with a few dummy records. Steve's solution should work with the addition of the quotes around the field name in the isnotblank() - actually the same thing I suggested.
              Hi Stan,

              I won't be able to send it until this evening as I have no internet access for my laptop at work and my work computer only has the RT.

              I did get this to work per your suggestion as well as Gabe's but using iif( , ,"").
              Using case( , , .t.) does not work.

              Thanks, kenn
              TYVM :) kenn

              Knowing what you can achieve will not become reality until you imagine and explore.

              Comment


              • #8
                Re: Proper use of 'Case'

                Using case( , , .t.) does not work.
                No one suggested

                Using case( , , .t.) because the case() function requires pairs of paramaters.

                The syntax is

                case(logical_test,result,anotherlogicaltest,result,.t.,lastchanceresult)

                the .t.,lastchanceresult

                says return lastchanceresult if all the previous logical tests failed.

                Note: .t. can be considered a logical test that always returns true.
                There can be only one.

                Comment


                • #9
                  Re: Proper use of 'Case'

                  Originally posted by Stan Mathews View Post
                  No one suggested

                  Using case( , , .t.) because the case() function requires pairs of paramaters.
                  So, I should use the IF ... THEN ... ELSE function; correct?

                  kenn
                  TYVM :) kenn

                  Knowing what you can achieve will not become reality until you imagine and explore.

                  Comment


                  • #10
                    Re: Proper use of 'Case'

                    Not if then else.

                    If(logical_test,true_result,false_result) works for one test. You can nest if()s like
                    If(logical_test,true_result,If(logical_test2,true_result,If(logical_test3,true_result,false_result)))

                    but pretty soon that becomes hard to maintain and edit.

                    Stick with the case() function and you expand from

                    case(logical_test,result,.t.,final_result)
                    to
                    case(logical_test,result,logical_test2,result2,.t.,final_result)
                    case(logical_test,result,logical_test2,result2,logical_test3,result3,.t.,final_result)
                    etc

                    The .t.,final_test is just a fail safe to make sure the case() function returns some value in every instance.
                    There can be only one.

                    Comment


                    • #11
                      Re: Proper use of 'Case'

                      Thank you, Stan!!

                      kenn
                      TYVM :) kenn

                      Knowing what you can achieve will not become reality until you imagine and explore.

                      Comment

                      Working...
                      X