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 Select vs. Case()

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

    Case Select vs. Case()

    If I use case() in an expression I believe there is a limit on 16 statements.

    If I use case select within a function there is not a limit?


    I have over 60 statements to determine the state a person's SSN was issued. Seeking confirmation that the number of statements used are acceptable.

    Thanks

    #2
    Re: Case Select vs. Case()

    You are correct

    Syntax is Select....case....end select

    Tom

    Comment


      #3
      Re: Case Select vs. Case()

      Gary,
      Not any better than your plan, but the case() can be used over and over again in an if-then to produce your results too such as the following using the 16th argument for a "Nextx" for the next case() function...
      Code:
      dim result as c
      dim temp as n
      temp=101
      result=case( TEMP < 32, "Cold", TEMP < 65, "Cool", TEMP < 80, "Warm", TEMP < 90, "Really Hot",TEMP>=90,"Next1" )
      if result="Next1"
        result=case(TEMP<100,"Really,Really Hot",TEMP>=100,"Extremely Hot!")
      end if
      ?result
      = "Extremely Hot!"
      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


        #4
        Re: Case Select vs. Case()

        case() in an expression I believe there is a limit on 16 statements.
        So the story goes and so says the help file.

        Not so.

        Check out this old thread.

        I think it was corrected in the help file.
        Last edited by G Gabriel; 12-29-2008, 06:00 AM.

        Comment


          #5
          Re: Case Select vs. Case()

          I didn't know that a component of the SSN denotes where it was issued from. Actualy, with a little research I learnt that it denotes the original place of residence. Since I have to get some sleep for now, I didn't go far enough to find the correlationship.

          If you know it, which I am assuming you do, and if you can outline it I believe there might be better ways to accomplish what you want without case or select.

          Later.
          Last edited by G Gabriel; 12-29-2008, 06:06 AM.

          Comment


            #6
            Re: Case Select vs. Case()

            G

            Thanks for the info on case(). I would have gone with what the help file stated without your info. I'll put that in my little books of "What is not said in the help file".

            Again thanks

            Tom

            Comment


              #7
              Re: Case Select vs. Case()

              Gary, I wonder if this might be a case (pardon me) where using a supporting table might help? If the table had two fields corresponding to the state and it's identification number, you could use one of the lookup() functions to retrieve the state name whenever you had an id number to check.

              Comment


                #8
                Re: Case Select vs. Case()

                Originally posted by Tom Cone Jr View Post
                Gary, I wonder if this might be a case (pardon me) where using a supporting table might help? If the table had two fields corresponding to the state and it's identification number, you could use one of the lookup() functions to retrieve the state name whenever you had an id number to check.
                This is the function I created to retrieve origin.

                Code:
                FUNCTION SSN_Data AS C (vSSN_Input as C)
                dim SSN_Valid as C
                
                SSN_Valid = case(len(remspecial(vSSN_Input))=9,"T", len(remspecial(vSSN_Input))<>9,"F")
                
                select
                    case SSN_Valid ="T"
                
                select
                case Left(vSSN_Input,3) >"000" .and. Left(vSSN_Input,3) <"004"
                	SSN_Data ="NH"
                case Left(vSSN_Input,3) >"003" .and. Left(vSSN_Input,3) <"008"
                	SSN_Data ="ME"
                case Left(vSSN_Input,3) >"007" .and. Left(vSSN_Input,3) <"010"
                	SSN_Data ="VT"
                case Left(vSSN_Input,3) >"009" .and. Left(vSSN_Input,3) <"035"
                	SSN_Data ="MA"
                case Left(vSSN_Input,3) >"034" .and. Left(vSSN_Input,3) <"040"
                	SSN_Data ="RI"
                case Left(vSSN_Input,3) >"039" .and. Left(vSSN_Input,3) <"050"
                	SSN_Data ="CT"
                case Left(vSSN_Input,3) >"049" .and. Left(vSSN_Input,3) <"135"
                	SSN_Data ="NY"
                case Left(vSSN_Input,3) >"134" .and. Left(vSSN_Input,3) <"159"
                	SSN_Data ="NJ"
                case Left(vSSN_Input,3) >"158" .and. Left(vSSN_Input,3) <"212"
                	SSN_Data ="PA"
                case Left(vSSN_Input,3) >"211" .and. Left(vSSN_Input,3) <"221"
                	SSN_Data ="MD"
                case Left(vSSN_Input,3) >"220" .and. Left(vSSN_Input,3) <"223"
                	SSN_Data ="DE"
                case Left(vSSN_Input,3) >"222" .and. Left(vSSN_Input,3) <"232"
                	SSN_Data ="VA"
                case Left(vSSN_Input,3) >"231" .and. Left(vSSN_Input,3) <"237"
                	SSN_Data ="WV"
                case Left(vSSN_Input,3) >"236" .and. Left(vSSN_Input,3) <"247"
                	SSN_Data ="NC"
                case Left(vSSN_Input,3) >"246" .and. Left(vSSN_Input,3) <"252"
                	SSN_Data ="SC"
                case Left(vSSN_Input,3) >"251" .and. Left(vSSN_Input,3) <"261"
                	SSN_Data ="GA"
                case Left(vSSN_Input,3) >"260" .and. Left(vSSN_Input,3) <"268"
                	SSN_Data ="FL"
                case Left(vSSN_Input,3) >"267" .and. Left(vSSN_Input,3) <"303"
                	SSN_Data ="OH"
                case Left(vSSN_Input,3) >"302" .and. Left(vSSN_Input,3) <"318"
                	SSN_Data ="IN"
                case Left(vSSN_Input,3) >"317" .and. Left(vSSN_Input,3) <"362"
                	SSN_Data ="IL"
                case Left(vSSN_Input,3) >"361" .and. Left(vSSN_Input,3) <"387"
                	SSN_Data ="MI"
                case Left(vSSN_Input,3) >"386" .and. Left(vSSN_Input,3) <"400"
                	SSN_Data ="WI"
                case Left(vSSN_Input,3) >"399" .and. Left(vSSN_Input,3) <"408"
                	SSN_Data ="KY"
                case Left(vSSN_Input,3) >"407" .and. Left(vSSN_Input,3) <"416"
                	SSN_Data ="TN"
                case Left(vSSN_Input,3) >"415" .and. Left(vSSN_Input,3) <"425"
                	SSN_Data ="AL"
                case Left(vSSN_Input,3) >"424" .and. Left(vSSN_Input,3) <"429"
                	SSN_Data ="MS"
                case Left(vSSN_Input,3) >"428" .and. Left(vSSN_Input,3) <"433"
                	SSN_Data ="AR"
                case Left(vSSN_Input,3) >"432" .and. Left(vSSN_Input,3) <"440"
                	SSN_Data ="LA"
                case Left(vSSN_Input,3) >"439" .and. Left(vSSN_Input,3) <"449"
                	SSN_Data ="OK"
                case Left(vSSN_Input,3) >"448" .and. Left(vSSN_Input,3) <"468"
                	SSN_Data ="TX"
                case Left(vSSN_Input,3) >"467" .and. Left(vSSN_Input,3) <"478"
                	SSN_Data ="MN"
                case Left(vSSN_Input,3) >"477" .and. Left(vSSN_Input,3) <"486"
                	SSN_Data ="IA"	
                case Left(vSSN_Input,3) >"485" .and. Left(vSSN_Input,3) <"501"
                	SSN_Data ="MO"
                case Left(vSSN_Input,3) >"500" .and. Left(vSSN_Input,3) <"503"
                	SSN_Data ="ND"
                case Left(vSSN_Input,3) >"502" .and. Left(vSSN_Input,3) <"505"
                	SSN_Data ="SD"
                case Left(vSSN_Input,3) >"504" .and. Left(vSSN_Input,3) <"509"
                	SSN_Data ="NE"
                case Left(vSSN_Input,3) >"508" .and. Left(vSSN_Input,3) <"516"
                	SSN_Data ="KS"
                case Left(vSSN_Input,3) >"515" .and. Left(vSSN_Input,3) <"518"
                	SSN_Data ="MT"
                case Left(vSSN_Input,3) >"517" .and. Left(vSSN_Input,3) <"520"
                	SSN_Data ="ID"
                case Left(vSSN_Input,3) >"519" .and. Left(vSSN_Input,3) <"521"
                	SSN_Data ="WY"
                case Left(vSSN_Input,3) >"520" .and. Left(vSSN_Input,3) <"525"
                	SSN_Data ="CO"
                case Left(vSSN_Input,3) >"524" .and. Left(vSSN_Input,3) <"526"
                	SSN_Data ="NM"
                case Left(vSSN_Input,3) >"525" .and. Left(vSSN_Input,3) <"528"
                	SSN_Data ="AZ"
                case Left(vSSN_Input,3) >"527" .and. Left(vSSN_Input,3) <"530"
                	SSN_Data ="UT"
                case Left(vSSN_Input,3) >"529" .and. Left(vSSN_Input,3) <"531"
                	SSN_Data ="NV"
                case Left(vSSN_Input,3) >"530" .and. Left(vSSN_Input,3) <"540"
                	SSN_Data ="WA"
                case Left(vSSN_Input,3) >"539" .and. Left(vSSN_Input,3) <"545"
                	SSN_Data ="OR"
                case Left(vSSN_Input,3) >"544" .and. Left(vSSN_Input,3) <"574"
                	SSN_Data ="CA"
                case Left(vSSN_Input,3) >"573" .and. Left(vSSN_Input,3) <"575"
                	SSN_Data ="AK"
                case Left(vSSN_Input,3) >"574" .and. Left(vSSN_Input,3) <"577"
                	SSN_Data ="HI"
                case Left(vSSN_Input,3) >"576" .and. Left(vSSN_Input,3) <"580"
                	SSN_Data ="DC"
                case Left(vSSN_Input,3) >"579" .and. Left(vSSN_Input,3) <"581"
                	SSN_Data ="VI"
                case Left(vSSN_Input,3) >"580" .and. Left(vSSN_Input,3) <"585"
                	SSN_Data ="PR"
                case Left(vSSN_Input,3) >"584" .and. Left(vSSN_Input,3) <"586"
                	SSN_Data ="NM"
                case Left(vSSN_Input,3) >"585" .and. Left(vSSN_Input,3) <"587"
                	SSN_Data ="PI"
                case Left(vSSN_Input,3) >"586" .and. Left(vSSN_Input,3) <"589"
                	SSN_Data ="MS"		
                case Left(vSSN_Input,3) >"588" .and. Left(vSSN_Input,3) <"596"
                	SSN_Data ="FL"
                case Left(vSSN_Input,3) >"595" .and. Left(vSSN_Input,3) <"600"
                	SSN_Data ="PR"
                case Left(vSSN_Input,3) >"599" .and. Left(vSSN_Input,3) <"602"
                	SSN_Data ="AZ"
                case Left(vSSN_Input,3) >"601" .and. Left(vSSN_Input,3) <"627"
                	SSN_Data ="CA"
                case Left(vSSN_Input,3) >"626" .and. Left(vSSN_Input,3) <"646"
                	SSN_Data ="TX"
                case Left(vSSN_Input,3) >"645" .and. Left(vSSN_Input,3) <"648"
                	SSN_Data ="UT"
                case Left(vSSN_Input,3) >"647" .and. Left(vSSN_Input,3) <"650"
                	SSN_Data ="NM"
                end select
                
                case SSN_Valid ="F"
                	SSN_Data =".."
                end select
                	
                END FUNCTION
                It first determines whether there are 9 digits. If there are then it determines where the person received their SSN based on the first 3 digits.

                I initially thought about using a database to retrieve the data but considered that this would require less space. If I were to decide that I wanted to also determine the year (period) the individual received their SSN then a table would definitely be required.
                Around 1985 it was mandatory for everyone to receive a SNN when they were born. Prior to this time the SSN would indicate in most cases a state residence when they began employment.

                Comment


                  #9
                  Re: Case Select vs. Case()

                  Gary,
                  are the case statements evaluating only the SSN, or is there evaluation of other values in the determination? If so, how many? I am with Gabriel on this. What are the elements in the matrix that evaluate to the state where the SSN was issued? When I see 60 statement to be evaluated, I'm thinking there must be a more concise way other than writing out 60 case statements.

                  Later:
                  I'm too slow a typer. I go with Tom's support table and a lookup. Get Cal or Ira on this to get us the speed numbers.
                  Last edited by Mike Wilson; 12-29-2008, 09:50 AM.
                  Mike W
                  __________________________
                  "I rebel in at least small things to express to the world that I have not completely surrendered"

                  Comment


                    #10
                    Re: Case Select vs. Case()

                    Originally posted by G Gabriel View Post
                    I didn't know that a component of the SSN denotes where it was issued from. Actualy, with a little research I learnt that it denotes the original place of residence. Since I have to get some sleep for now, I didn't go far enough to find the correlationship.

                    If you know it, which I am assuming you do, and if you can outline it I believe there might be better ways to accomplish what you want without case or select.

                    Later.
                    Around 1985 it was required for all individuals to receive a SSN when they were born. Prior to that time period individuals received a SSN when needed. Employment mostly.

                    The first 3 digits indicate the issuing state. The 2nd second set of numbers is a time period. Generally a year or years. This set of numbers is rotated and not issued in numerical order. The third set of numbers is nothing more than just a batch of numbers like the phone company will allot to competitors within a phone prefix.

                    I'm not sure there is a better way to accomplish it other than using the case select method in this instance. If the numbers were in a total mumbo jumbo I would use a table instead. See my response with the coding that I used.

                    Comment


                      #11
                      Re: Case Select vs. Case()

                      Originally posted by Mike Wilson View Post
                      Gary,
                      are the case statements evaluating only the SSN, or is there evaluation of other values in the determination? If so, how many? I am with Gabriel on this. What are the elements in the matrix that evaluate to the state where the SSN was issued? When I see 60 statement to be evaluated, I'm thinking there must be a more concise way other than writing out 60 case statements.

                      Later:
                      I'm too slow a typer. I go with Tom's support table and a lookup. Get Cal or Ira on this to get us the speed numbers.
                      See my coding above for the statements.

                      Comment


                        #12
                        Re: Case Select vs. Case()

                        If the supporting table had 650 records, indexed on the three digit "state identifier" I'd expect LOOKUPC() to be virtually instantaneous. Most of the time would be spent opening and closing the supporting table.

                        Pre-filling an array with 650 entries would be another way to approach this.

                        -- tom

                        Comment


                          #13
                          Re: Case Select vs. Case()

                          Hi Gary,

                          While the select case (which effectively is the same as IF-ELSE IF-END IF construct in speed) can be used, I'd think this would be more of a lookup in a list or table. I'd do it like this (but you'd need to fill out the rest of the state list) as an alternative. My version is probably is a bit faster (but not by a lot I suspect) and both are workable solutions.

                          Code:
                          FUNCTION SSN_Data AS C (vSSN_Input as C)
                          
                          dim SSN_Valid as C
                          SSN_Valid = case(len(remspecial(vSSN_Input))=9,"T", len(remspecial(vSSN_Input))<>9,"F")
                          
                          ' Change 999 to maximum value if lower
                          IF (SSN_Valid=="F") .or. (.not.(between(val(Left(vSSN_Input,3)),1,999)))
                              SSN_Data =".."
                              EXIT FUNCTION
                          END IF
                          
                          dim statelist as c
                          
                          ' Fill in the rest of the state list below, 20 per line
                          ' 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
                          statelist=""+\
                          "NH,NH,NH,ME,ME,ME,ME,VT,VT,MA,MA,MA,MA,MA,MA,MA,MA,MA,MA,MA,"+\
                          "MA,MA,MA,MA,MA,MA,MA,MA,MA,MA,MA,MA,MA,MA,RI,RI,RI,RI,RI,CT,"+\
                          "CT,CT,CT,CT,CT,CT,CT,CT,CT,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,"+\
                          "NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,"+\
                          "NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,"+\
                          "NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,"+\
                          "NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NY,NJ,NJ,NJ,NJ,NJ,NJ,"+\
                          ""
                          ' 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
                          SSN_Data=WORD(statelist,val(Left(vSSN_Input,3))+1,",")
                          END FUNCTION
                          One comment I'd add about your select conditonals, is that it is harder to follow with the way you did it. Changing it to below does not affect speed and is easier to see the ranges
                          Code:
                          case Left(vSSN_Input,3) >= "001" .and. Left(vSSN_Input,3) <= "003"
                              SSN_Data ="NH"
                          case Left(vSSN_Input,3) >= "004" .and. Left(vSSN_Input,3) <= "007"
                              SSN_Data ="ME"
                          case Left(vSSN_Input,3) >= "008" .and. Left(vSSN_Input,3) <= "011"
                          You could also have pre-calculated Left(vSSN_Input,3) which would save a small bit in many reuses of the same value.

                          Finally, you could use BETWEEN() to test the range. In the below example, I changed it to a number 1st, but a string argument could be used as well.

                          Code:
                          dim ssnumb as n
                          ssnumb=val(Left(vSSN_Input,3))
                          
                          select
                          case between(ssnumb,1,3)
                              SSN_Data ="NH"
                          case between(ssnumb,4,7)
                              SSN_Data ="ME"
                          case between(ssnumb,8,9)
                              SSN_Data ="VT"
                          Regards,

                          Ira J. Perlow
                          Computer Systems Design


                          CSDA A5 Products
                          New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                          CSDA Barcode Functions

                          CSDA Code Utility
                          CSDA Screen Capture


                          Comment


                            #14
                            Re: Case Select vs. Case()

                            As far as the select ... case format goes I use the below format for this type of range. The selection will stop at the first true expression so you only really need to enter the bottom end of the next range.

                            Code:
                            select
                            case Left(vSSN_Input,3) <"004"
                                SSN_Data ="NH"
                            case Left(vSSN_Input,3) <"008"
                                SSN_Data ="ME"
                            case Left(vSSN_Input,3) <"010"
                                SSN_Data ="VT"
                            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


                              #15
                              Re: Case Select vs. Case()

                              Hi Tim,

                              Originally posted by Tim Kiebert View Post
                              As far as the select ... case format goes I use the below format for this type of range.
                              Good point, and it does look like the states are not scattered around. But if you were doing something with say, the 1st 3 positions of a US zip code, you'd find unused numbers as well as ones that seem to show up in odd positions, so in that kind of case, you'd need to use a table/list method or a range of numbers.
                              Regards,

                              Ira J. Perlow
                              Computer Systems Design


                              CSDA A5 Products
                              New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                              CSDA Barcode Functions

                              CSDA Code Utility
                              CSDA Screen Capture


                              Comment

                              Working...
                              X