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

Case expression not working.

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

    Case expression not working.

    Hi all,

    One more for today, I am trying to create a calculation for a field that creates a description. I know the calculation works exactly the way I want it to in a different program (filemaker pro) but I am having a hard time converting the syntax to AA.

    This is what it looks like in FMP.

    Case(IsEmpty(Name_First) and IsEmpty(Name_Last);Street_1; //result 1
    IsEmpty ( Name_First) ;Name_Last & " " & Street_1 ; //result 2
    IsEmpty (Name_Last) ;Name_First & " " & Street_1 ; //result 3
    Name_First & " " & Name_Last & " " &Street_1 //default result
    ))

    I can get as far as


    CASE(ISNULL(NAME_FIRST).AND.ISNULL(NAME_LAST),STREET_1, //result 1
    ISNULL(NAME_FIRST),NAME_LAST+" "+STREET_1, //result 2
    ISNULL(NAME_LAST),NAME_FIRST+" "+STREET_1 //result 3


    )



    without any errors,l but cant figure out how to get the last default value or a fourth argument to work. I've tried

    CASE(ISNULL(NAME_FIRST).AND.ISNULL(NAME_LAST),STREET_1, //result 1
    ISNULL(NAME_FIRST),NAME_LAST+" "+STREET_1, //result 2
    ISNULL(NAME_LAST),NAME_FIRST+" "+STREET_1, //result 3
    ISNOTBLANK(NANE_FIRST).AND.ISNOTBLANK(NAME_LAST).AND.ISNOTBLANK(STREET_1),NAME_FIRST+" "+NAME_LAST+" "+STREET_1
    )

    It won't evaluate once I try the ISNOTBLANK which is a valid function (I think)

    Also I have tried just using the top calculation that I can get to work (not give me an error msg) but it doesn't calculate on my form. How do I get it to automatically calculate as I fill in the three fields. I have created this calculation in the field rules on the tables tab but it doesn't auto calculate on my corresponding form.

    I'm anxiously waiting for everything to start make sense in AA coming from FMP.

    Thanks Again
    Marc
    Thanks,

    Marc McCall

    Version 12.3 2128 -4292
    MySQL backend

    If at first you don�t succeed, call it version 1.0

    #2
    Re: Case expression not working.

    It's not because you have NANE_FIRST instead of NAME_FIRST is it?
    Other than that, I'm worthless on the desktop side of AA

    Comment


      #3
      Re: Case expression not working.

      No that is a typo, I hand typed the last bit because I couldn't get is to save in the expression builder with it that line in it.
      Thanks,

      Marc McCall

      Version 12.3 2128 -4292
      MySQL backend

      If at first you don�t succeed, call it version 1.0

      Comment


        #4
        Re: Case expression not working.

        Are you trying to present name and address formatted properly when data is missing?

        If so, look at a RTF (Rich Text Field) with a soft-return.

        Otherwise let us know what you want the application to do, and we can suggest a way to accomplish it.
        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


          #5
          Re: Case expression not working.

          I'm trying to create an address description automatically based off of the contents of the three fields. Address_description = Name_first+" "+Name_Last+" "+Street_1
          But I do not want the extra spaces if Name first is empty or last name is empty, hence the case statement.

          I really don't know how to better describe what I'm trying to do than my first post it pretty much answers everything. I'm trying to create a calculated field that automatically calculates based on what is in the other tree fields.
          Thanks,

          Marc McCall

          Version 12.3 2128 -4292
          MySQL backend

          If at first you don�t succeed, call it version 1.0

          Comment


            #6
            Re: Case expression not working.

            Working with native AA tables ( i.e. dbf format ) ?

            Comment


              #7
              Re: Case expression not working.

              Yes, native .dbf
              Thanks,

              Marc McCall

              Version 12.3 2128 -4292
              MySQL backend

              If at first you don�t succeed, call it version 1.0

              Comment


                #8
                Re: Case expression not working.

                Originally posted by DDPMarc View Post
                I'm trying to create an address description automatically based off of the contents of the three fields. Address_description = Name_first+" "+Name_Last+" "+Street_1
                But I do not want the extra spaces if Name first is empty or last name is empty, hence the case statement.

                I really don't know how to better describe what I'm trying to do than my first post it pretty much answers everything. I'm trying to create a calculated field that automatically calculates based on what is in the other tree fields.
                So the context is to show the name and address nicely on a printed document? What I was asking for is what you are trying to accomplish with the technical solution that you are discussing. Usually technical solutions are driven by a non-technical need.

                Using the RTF with calculated fields and soft-returns is what you are looking for. Way too hard to use a function for that job. Too many options and it gets confusing.

                Every tool has it's nuances. For Alpha I use the RTF for exactly this purpose (and a couple of more).

                In Crystal Reports, you'd use a text box with some calculated fields and click the suppress blank lines option.

                Don't know Filemaker well enough to suggest a method for it. (Only for comparison purposes.) FM may not have an option, so you used the method you described.

                Look at this section of the help file for detailed info...

                http://wiki.alphasoftware.com/~alpha...ch+Text+Fields
                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


                  #9
                  Re: Case expression not working.

                  Actually I need the result of the calculation stored in the database record. It will later at some point be used in a script to build an http_get URL to send the data in the URL and then consume the response, but this is later down the road.

                  As I said before I know the calculation works in FMP that is where i originally wrote it. I am transitioning from FMP to AA and want to convert a solution I made in FMP to AA. Once I get the initial solution built I am going to add a lot more function to it that otherwise would not be possible with FMP.

                  This is the very first calculation I have attempted to put together so it hasn't clicked just yet how to do it in AA. I've been using FMP for about 10 years now, I've only been using AA for about a week.

                  Way too hard to use a function for that job.
                  The documentation says that a case statement can evaluate an additional 15 expressions so I don't know how it would be to hard for this to work. In FMP it is lightning fast.

                  Any help, pointers or links to how to use calculated fields in a native dbf format for desktop would be appreciated. I'm pretty sure once I get a few fields calculating the way I want I'll be off and running, just like i was in FMP years ago.
                  Thanks,

                  Marc McCall

                  Version 12.3 2128 -4292
                  MySQL backend

                  If at first you don�t succeed, call it version 1.0

                  Comment


                    #10
                    Re: Case expression not working.

                    Thank you all for attempting to help with this, I figured it out.

                    CASE(ISNULL(NAME_FIRST).AND.ISNULL(NAME_LAST),STREET_1,
                    ISNULL(NAME_FIRST),NAME_LAST+" "+STREET_1,
                    ISNULL(NAME_LAST),NAME_FIRST+" "+STREET_1,
                    ISNOTBLANK("name_first").AND.ISNOTBLANK("name_last").AND.ISNOTBLANK("street_1"),TRIM(NAME_FIRST)+" "+TRIM(NAME_LAST)+" "+TRIM(STREET_1))

                    Thanks
                    Marc
                    Thanks,

                    Marc McCall

                    Version 12.3 2128 -4292
                    MySQL backend

                    If at first you don�t succeed, call it version 1.0

                    Comment


                      #11
                      Re: Case expression not working.

                      A common malady.

                      the IsNotBlank() function takes a character argument, so the field name passed to the function must be enclosed in quotes.

                      ISNOTBLANK("Name_First")

                      NOT

                      ISNOTBLANK(Name_first)

                      Later I see you figured it out while I was typing! Good for you, and thanks for posting the final result. -- tom

                      Comment


                        #12
                        Re: Case expression not working.

                        1. Then go the other way and build it step by step so you can see what works and what doesn't.

                        ISNULL() may not be a good choice since there may be a space value in the field and dbf's are not designed with NULL in mind.

                        2. Build your own UDF (User Defined Function) and build the result in a series of steps that uses an easier framework and no iteration limitation.

                        http://wiki.alphasoftware.com/~alpha...ined+Functions

                        the flow of the code would be something like this:
                        Code:
                        output=""
                        
                        if first_name>"" then
                        
                           output = output + first_name
                        
                        end if
                        
                        if last_name>"" then
                        
                          if output>"" then
                        
                          output = output + " "+ last_name
                        
                          else 
                        
                          output = output + last_name
                        
                          end if
                        
                        end if
                        
                        'add crlf() if some part of the name is there.
                        
                          if output>"" then
                        
                          output = output + crlf()
                        
                          end if
                        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


                          #13
                          Re: Case expression not working.

                          Originally posted by DDPMarc View Post
                          Thank you all for attempting to help with this, I figured it out.

                          CASE(ISNULL(NAME_FIRST).AND.ISNULL(NAME_LAST),STREET_1,
                          ISNULL(NAME_FIRST),NAME_LAST+" "+STREET_1,
                          ISNULL(NAME_LAST),NAME_FIRST+" "+STREET_1,
                          ISNOTBLANK("name_first").AND.ISNOTBLANK("name_last").AND.ISNOTBLANK("street_1"),TRIM(NAME_FIRST)+" "+TRIM(NAME_LAST)+" "+TRIM(STREET_1))

                          Thanks
                          Marc
                          Hi Mark,
                          In the last test you don't really need to check the firstname and lastname fields because you have already deternined by this point (in the first line) that either are not blank. That leaves only testing for street_1, but earlier you don't test for street_1 being empty. If street_1 is empty you could end up with 1/a pass with an empty result, 2/a pass with only last name, 3/a pass with only first name, 4/ a fail - no result.

                          So if an empty result is allowable, which both line 1 and line 4 will give you, then you can accomplish the same thing with this...
                          Code:
                          LTRIM(NAME_FIRST-" "+NAME_LAST-" "+STREET_1-"")
                          See here for an explanation of the ' - ' http://wiki.alphasoftware.com/-+Conc...+Trim+Operator
                          Last edited by Tim Kiebert; 05-06-2014, 09:16 PM.
                          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


                            #14
                            Re: Case expression not working.

                            @Tim that is definitely a much simpler solution, thanks.

                            @Al, that would be nice, I will definitely be looking into building UDF's I will need to find some more documentation on how to actually use the Create New Function dialog.
                            Thanks,

                            Marc McCall

                            Version 12.3 2128 -4292
                            MySQL backend

                            If at first you don�t succeed, call it version 1.0

                            Comment


                              #15
                              Re: Case expression not working.

                              Marc,
                              Creating a UDF is nothing more than a script enclosed into a FUNCTION - END FUNCTION with lots of added possibilities and benefits. I use almost exclusively UDFs. Go to the Code tab in control panel, select NEW from toolbar and chose FUNCTION from dropdown menu. Name the function 'say_hello' . Type in: msgbox("Hello Marc") between the FUNCTION - END FUNCTION, and then under the END FUNCTION type in - say_hello() Now either press the lightning bolt to run the function or save it and go to Interactive Window and type in say_hello() and then <enter>. This calls the UDF and the msgbox dialog with "Hello Mark" will show. You are now on your way using UDFs.
                              Mike W
                              __________________________
                              "I rebel in at least small things to express to the world that I have not completely surrendered"

                              Comment

                              Working...
                              X