Child pages
  • Custom Functions » Script Parameter Interface

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updating links

...

These functions implement the basics of adding data to and retrieving data from dictionary data structures.

# ( name ; value )

The # ( name ; value ) function creates a name-value pair. A dictionary data structure can be created by concatenating several calls to #() as if they were plain text. Name-value pairs can be nested.

...

By placing the defaults before the actual parameters, any values set by the actual script parameter will override the defaults.

#Assign ( parameters )

The #Assign function parses a dictionary into locally-scoped script variables. The name from each name-value pair is used as the variable name, and the value from each pair is used as that variable's value.

...

The #Assign function returns True (1) if there was no error detected while assigning the values to variables, and returns False (0) otherwise. If there was an error detected, FileMaker's error code is assigned to the $#Assign.error variable.

#Get ( parameters ; name )

The #Get function returns a named value from a dictionary.

...

These functions are less fundamental to working with dictionary data structures than the core functions, but experience has demonstrated that this functionality can be indispensable in practical applications.

#AssignGlobal ( parameters )

The #AssignGlobal function parses a dictionary into global variables.

...

The #AssignGlobal function returns True (1) if there was no error detected while assigning the values to variables, and returns False (0) otherwise. If there was an error detected, FileMaker's error code is assigned to the $#AssignGlobal.error variable.

#Filter ( parameters ; filterParameters )

The #Filter function returns a dictionary containing only those name-value pairs where the name is included in the return-delimited list filterParameters.

...

This function can prevent an "injection" of unexpected variables that might cause problems.

#GetNameList ( parameters )

The #GetNameList function returns a list of names from all name/value pairs in parameters. This is useful when you don't know what names exist, and you want to iterate through all the name/value pairs that exist.

Code Block
#GetNameList (
	# ( "name" ; "value" )
	& # ( "foo" ; "bar" );
)
= List ( "name" ; "foo" )

#Remove ( parameters ; removeParameters )

The #Remove function returns a dictionary containing only those name-value pairs where the name is not included in the return-delimited list removeParameters. This is complementary to the #Filter function.

Code Block
#Assign ( #Remove (
	# ( "name" ; "value" )
	& # ( "otherName" ; "otherValue" )
	& # ( "foo" ; "bar" ) ;
	List ( "name" ; "otherName" )
) ) // $foo is assigned "bar"; $name and $otherName are unaffected

ScriptOptionalParameterList ( scriptNameToParse )

The ScriptOptionalParameterList function parses a script name, returning a return-delimited list of optional parameters for that script, in the order they appear in the script name. This function assumes that the script name conforms to the FileMakerStandards.org naming convention for scripts.

...

Code Block
ScriptOptionalParameterList ( "" ) = ScriptOptionalParameterList ( Get ( ScriptName ) )

ScriptRequiredParameterList ( scriptNameToParse )

The ScriptRequiredParameterList function parses a script name, returning a return-delimited list of parameters required for that script, in the order they appear in the script name. This function assumes that the script name conforms to the FileMakerStandards.org naming convention for scripts. This is useful to generate the argument used by the VerifyVariablesNotEmpty function to validate that all required parameters have values. When the scriptNameToParse parameter is empty, the function will use the current script name.

...

Code Block
ScriptRequiredParameterList ( "Script Name ( required1 ; required2 ; { optional1 ; optional2 } )" )
= List ( "required1" ; "required2" )

VerifyVariablesNotEmpty ( nameList )

The VerifyVariablesNotEmpty function returns True (1) if each of the parameters in nameList has been assigned to a non-empty variable of the same name. The function returns False (0) if any variable defined by nameList is empty. This is useful for verifying that each parameter required by a script has been successfully assigned before proceeding.

...

These functions are documented for backwards compatibility. These functions are all equivalent to simple combinations of other functions, which can make the functionality more self-describing, especially for developers who may be unfamiliar with them.

#AssignScriptParameters

The #AssignScriptParameters function will assign all named values in the script parameter to local script variables of the same name. If any parameters indicated as required by the script name are empty, the function returns False (0); the function returns True (1) otherwise.

...

This approach enables greater flexibility in defining what variables are required and how those variables are assigned.

#AssignScriptResults

This function is exactly equivalent to this calculation:

Code Block
#Assign ( Get ( ScriptResult ) )

#GetScriptParameter ( name )

This function is exactly equivalent to this calculation:

Code Block
#Get ( Get ( ScriptParameter ) ; name )

#GetScriptResult ( name )

This function is exactly equivalent to this calculation:

...