Commenting, naming and numbering FileMaker scripts costs time now but saves far more later, two senior developers argue.
Nick gives pretty much 15% of his time to keeping the system behind the scenes neat, clean and documented, and says it is extremely time consuming. Down the road you save a lot of time: two or three weeks later there is no way you remember what you were doing.
You put a pound or hashtag sign on the line, then whatever note you want. Comments are things that will not activate; they are purely notes, and only someone writing the script sees them. They help you understand what you were doing and thinking at the time you wrote it.
Explain as much as you can. Some scripts have a dependency when you write them: you assume you are on a certain layout before the script is activated. Say that at the top, that this script assumes a certain layout with a certain record, or say there are no dependencies and it runs anywhere.
Nick says with a long script you have trouble keeping track from the top to the bottom, and you carry more risk because you may conflict with what you did before and cannot see clearly which context you are in. He once deleted records in the wrong context and lost all his invoices.
Nick puts the action first: add, validate, cancel, import, show, delete, go to. Then what the script is, such as trigger, then where it fires from, like on layout keystroke or on layout enter. That groups all the validates or all the adds together, so naming extends the comments.
FileMaker does not use the name to know which script or layout to call; it uses a hidden ID number, so every script could share a name and it would still work. The numbering is for us, not FileMaker. Richard asks customers for the number, 131, rather than the descriptive name, because dialogs chop the rest off.
It is the control key with return. Instead of each comment row becoming another script line and pushing you to line 267, you add multiple rows within a single comment, so verbose commenting does not increase your line numbers by ten. Nick expects it is the same on Windows and asks Windows people to confirm.
Nick demonstrates live: pressing no key returns zero, alt returns 8, command returns 16, and alt and command together return 24, which is 16 plus 8. He uses it constantly, for example deleting records with no dialogue when alt is held. Caps lock changes every value, which makes it a nightmare.
If you copy something like a social security number, close FileMaker and somebody else goes to that machine, they can see it, which is a breach of security. The other concern is that it is extremely slow, because you suck things out of FileMaker and then pull them back in when you paste.
There is no easy way, only a hack. In a copy of your original file, rename the relationships, table occurrences, fields and layout exactly the way they are named in the destination file, then copy the script and paste it there. Nick does this all the time and says it saved him hours of work.
“It's very short because when you code, you don't have time to read a novel.”
“I'm not going to remember why I did it.”
“Some things I think are non-negotiable.”
“FileMaker Scripting for Beginners - Day 1 - What not to do.” https://www.youtube.com/live/fIC7sapR_j0. Transcript summary by WhipScribe, https://whipscribe.com/transcript-pages/filemaker-scripting-for-beginners-day-1-what-not-to-do.html.