Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7325 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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

Posted

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"...

Posted

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?

Posted

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.

  • Like 1
Posted

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.

Posted

Fenton, can you elaborate on the limitation or post a sample file demonstrating it?

Posted

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

Posted

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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.