Choose — Caution IMO the documentation is slightly faulty in its example for the “integer” use of this command. The issue is that Choose returns the “null” value for the type being used if the integer value is not in the range covered.
From the Documentation * * * * * * * * * * * * * * * * * * * * * Example 2 Here is an example of the typical use of this command with a Number type criterion: vStatus:=Choose([Person]Status;"Single";"Married";"Widowed";"Divorced") This code is strictly equivalent to: Case of :([Person]Status=0) vStatus:="Single" :([Person]Status=1) vStatus:="Married" :([Person]Status=2) vStatus:="Widowed" :([Person]Status=3) vStatus:="Divorced" End case * * * * * * * * * * * * * * * * * * * This is not "strictly" correct. You need to add an Else to the Case statement to get complete equivalency The null value of the type (in this case "") is returned if the integer value is out of range (in this case the range is 0-3) Case of :([Person]Status=0) vStatus:="Single" :([Person]Status=1) vStatus:="Married" :([Person]Status=2) vStatus:="Widowed" :([Person]Status=3) vStatus:="Divorced" Else vStatus:="" End case So if vStatus had some other value going into the Choose statement, it is going to loose that value even if there was no matching criteria. > On Jul 6, 2017, at 9:45 AM, Chip Scheide via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > I found out about a command I had not known about > Choose > > I love this command > if anyone does not know about it - read it is so nice to do in one > line of code what other wee takes at least5 ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************