This simple calculation returns a boolean of wether the current year is a leap year or not.
Case(
IsEmpty(Current Date), TextToNum(""),
Mod(Year(Current Date),4) = 0
and
Mod(Year(Current Date),100) <> 0
or
Mod(Year(Current Date),400) =0 , 1, 0
)
Useful hints, tips and tricks for FileMaker Developers
This simple calculation returns a boolean of wether the current year is a leap year or not.
Case(
IsEmpty(Current Date), TextToNum(""),
Mod(Year(Current Date),4) = 0
and
Mod(Year(Current Date),100) <> 0
or
Mod(Year(Current Date),400) =0 , 1, 0
)
Sometimes you may want a field to always be in uppercase characters, however the user may input it. It is possible to just format a field to show the text as uppercase, but the actual field data would remain in lower or mixed case.
To actually force the data to be uppercase we can use an auto-entered calculation. Open the Manage Database dialog (File > Manage > Database…) and open the options for the field you want to change. In the Auto-Enter section check the ‘Calculated value’ checkbox and when the calculation dialog opens, type Upper(FieldName) replacing FieldName with the name of the field, or if you are using FileMaker 9 you can use Upper(Self) which automatically uses the current field.
Click OK and then make sure you uncheck ‘Do not replace existing field value (if any)’, otherwise it won’t work. Close the field options and now all data will automatically be changed to uppercase when the field is exited.
When you are automating exports of user data from a FileMaker file, the easiest place for the user to be able to find the exported file at a later date is on the desktop. How can you export a file there? Using the Get(DesktopPath) script function!
It returns the path to the desktop folder with a trailing slash ready for you to append a filename to, for example:
$file = Get(DesktopPath) & “export.xml”
Would return something like ‘/C:/Documents and Settings/Username/Desktop/export.xml‘ on a Windows machine and something similar to ‘/MacintoshHD/Users/Username/Desktop/export.xml‘ on a Mac.
If you save it to a variable you can then use it in an export path to enable dynamic export paths to the user’s desktop, without having to know their platform and system username.
When designing a layout in FileMaker you quite often want an object to look exactly the same as another, for example when laying out lots of fields. You could use the Duplicate menu command in the edit menu, or the keyboard shortcut for that, Ctrl + D / Command + D.
Another, even easier way is to just hold down the Control key on PC (or Option key on a Mac) whilst dragging the layout object you want to duplicate and a ‘+’ sign will appear next to the pointer to show that you are duplicating the control and not just moving the original, which it would do if you weren’t holding down control/option the whole time you are dragging the control.
If you do accidently let go of the modifier key before you finish dragging and then end up moving the original control instead of duplicating it, you can easily reverse the change by using the Undo command in the Edit menu, or use the keyboard shortcut Control + Z (Command + Z on Mac)
If for whatever reason you don’t want to use the Send Mail script step, you can achieve the same by using the Open URL script step as well.
Just use something like the following as the address:
“mailto:” & Email_Address & “?Subject=” & Subject & “?Body=” & Message
Where you change Email_Address, Subject and Message to hardcoded values, variables or fields.
It will open up a new message to be sent from the default installed mail client the same as the Send Mail step does.
I was asked by a colleague the other day for a custom function to convert millimeters into a readable format of feet and inches, for example 1000mm = 3 ft 3 5/16″, I didn’t know of such a function so I made it myself and here it is:
| Function Name: | ConvertMM | |
| Function Parameters: | MM | |
| Function Code | ||
| Let ( [ inches = MM * .03937008; feet = Floor ( inches/12 ); inches = Mod ( inches ;12 ); num = Floor(inches); sixteenths = Abs(Floor((inches - num) * 16)); ret = Case ( (Mod(sixteenths; 2) =1) ;num & " " & sixteenths & "/16" ; sixteenths = 2 or sixteenths = 6 or sixteenths = 10 or sixteenths = 14; num & " " & sixteenths / 2 & "/8" ; sixteenths = 4 or sixteenths = 12 ; num & " " & sixteenths / 4 & "/4" ; sixteenths = 8 ; num & " 1/2" ; num ) ]; feet & ” ft ” & ret & “\”" ) |
||
| Example Input: | 1000 | |
| Example Output: | 3 ft 3 5/16″ | |
| Example Usage: | $inches = ConvertMM(1000) |