barry_c Posted November 3, 2004 Posted November 3, 2004 Hi Forum, Even though I've just been using FMP a short time I've gotten a lot of priceless help here and so rather than just take, take, take, all the time I thought I would post a humble little solution I was able to come up with on my own. I'm sure that there are other, more elegant approaches to the problem and I would be curious to see them... I need to send dated forms to Latin America and so Iwas looking for a way to translate the date into Spanish. (While in the US we use a MM/DD/YYYY format, in Latin America they use DD/MM/YYYY, so I was going to need to manipulate the date info at some point.) So I added a date field (with white text) called "DATE_IN" and another field called "DATE_OUT" with the calculation Case ( DayOfWeek ( DATE_IN ) = 1; "Domingo"; DayOfWeek ( DATE_IN )= 2; "Lunes"; DayOfWeek ( DATE_IN )= 3; "Martes"; DayOfWeek ( DATE_IN )= 4; "Miercoles"; DayOfWeek ( DATE_IN )= 5; "Jueves"; DayOfWeek ( DATE_IN )= 6; "Viernes"; DayOfWeek ( DATE_IN )= 7; "S
-Queue- Posted November 3, 2004 Posted November 3, 2004 You can use Choose and combine your text concatenations to simplify this to Choose( DayOfWeek(DATE_IN) - 1; "Domingo"; "Lunes"; "Martes"; "Miercoles"; "Jueves"; "Viernes"; "S
barry_c Posted November 4, 2004 Author Posted November 4, 2004 Good point, thanks for pointing that out. But in this case the day names come at the beginning of a line (or in their own field), in which case they are capitalized. Month names follow the same rule - since these come in the middle of the phrase "Lunes, 3 de mayo 2004" But now that I think about it, it would probably best read, "Lunes, 3 de mayo del 2004"...
barry_c Posted November 4, 2004 Author Posted November 4, 2004 Interesting about the choose function - I never would have thought you would need the "-1" in there. Doesn't Month(DATE_IN) just read the month of 5/3/2003 as "5"? Why does choose require us to subtract one but case does not? And why does it work for January if there is no "0" month?
BrentHedden Posted November 4, 2004 Posted November 4, 2004 you need the -1 because just about any programming language starts out with 0, not 1. Although we tend to start counting at "1", a computer starts at "0". This is the same with arrays (if you ever use them) If you didn't include the "-1", then "Domingo" would never show up. 1
Fenton Posted November 4, 2004 Posted November 4, 2004 From FileMaker Help on the Choose function: "Because the index is a 0 based index, the test result must be 0 to access the first result." Choose is a little different from most FileMaker functions. I've run into a limitation, when trying to use a list that was stored in a global field or another calculation. Unlike most other FileMaker calculation functions, Choose will only work with a hard-coded list, directly in its calculation; it cannot reference a list outside itself. If anyone knows a trick to overcome this limitation, I'd love to hear it. Otherwise, it is useful, because it is faster than Case, if you can type in the choices.
-Queue- Posted November 4, 2004 Posted November 4, 2004 Fenton, can you elaborate on the limitation or post a sample file demonstrating it?
Fenton Posted November 4, 2004 Posted November 4, 2004 Just try to put your list of things to Choose from into a global field. No matter how I format that list, I'm getting the entire global field for 0, but nothing for any other number. ChooseIt.zip
-Queue- Posted November 4, 2004 Posted November 4, 2004 Oh, I see what you mean. This makes sense though. You only have one result for Choose, which will only be returned when ChoiceNum is zero, as per its definition, and the result for zero is the entire field. You have no result specified for 1, etc. I would use something like MiddleWords( _gChoices; ChoiceNum; 1 ) in this case anyway.
Recommended Posts