In FOCUS we take advantage of FileMaker script groups to organize scripts into logical sections. We also have a convention where if a script is called by another script, that the script name be preceded with a period. For example the script “b create record ( table )” is a script that is attached to a button on the layout and when it is called it may call the following script “. create generic ( table )”
Another thing that we strive for with FOCUS is the ability to black box all of our scripts such that they can be easily copied or run from any context. As long as the script receives the parameters it is looking for, the script can be called from any place.
Parameters are a big part of FOCUS and we use a parameter passing technique that sixfriedrice came up with. Basically, it is a name value pair encoding that allows us to easily send a script one or more parameters, and then have the script unpack them. The two custom functions that we use to set parameter and get parameters are:
GetParameter
#( key, value )
// SetParameter ( key ; value )
// Returns a dictionary entry with name and value
// SetParameter("ID", 2) &
SetParameter("NAME", "bill")
"<:" & key & ":=" & "TEXT" & ":=" & Substitute ( value ; [ "=" ; "/=" ] ; [ ":" ; "/:" ] ; [ ">" ; "/>" ] ; [ "<" ; "/<" ] ) & ":>"
SetParameter
#P ( name )
// GetParameter ( name )
// Assuming the script parameter contains a dict, returns the value of key 'name' in the script parameter
// GetParameter ("ID")
DictGet ( Get ( ScriptParameter ) ; key )
These two custom functions are incredibly useful, reliable and powerful. They are used not only in scripts to move parameters from one script to the next, but also on buttons, triggers and custom menus. Basically anywhere you need to send a parameter to a script, this is the method used.
Comments