Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Understanding Script Parameter used with Evaluate function


Norma_Snockurs
 Share

Recommended Posts

I am having a bit of a mental block with understanding the 'Evaluate' function. What I am trying to do is pass several different field values of mixed types (text, number, date etc) from one script to another using a single Script parameter. I can't do it with Global script variables because the two scripts concerned are in different files.

 

It would appear that the best way of going about this is to use the 'Evaluate' function with Get(Script Parameter) in the receiving script. However the FileMaker documentation regarding this function is, as ever, as clear as mud to me.

 

Anyone care to try and improve on the FM docs by clarifying how 'Evaluate' works in this context? Cheers in advance.

Norm. smiley-laughing

Link to comment
Share on other sites

Evaluate treats a text string as if it's calculation code. So if your script parameter value can be read as code, then it will return a value if it can. So that would have to be working code in the context of the receiving file and script. I'm not really sure this is what you need. can't you build the parameter value as a text string, e.g

TextField &"|"& NumberField &"|"& DateField

and then parse the values out to the separate fields or variables you need in the receiving script?

 

I have not tried the latter myself but I have seen it described somewhere. It seems a feasible option.

 

maarten

 

PS I have built a calculation editor a while back that makes use of the evaluate function. it's here. It seems kind of clunky after more than a year, and it's far from complete, but it was nice to horse around with it.

Link to comment
Share on other sites

Watch out for the danged quotation marks. That which is to be evaluated must be in quotation marks.

 

Evaluate("Get(ScriptParameter)")

 

not

 

Evaluate (Get(ScriptParameter) )

 

or for that matter

 

Evaluate ("Case(Get(ScriptParameter)=1, Parameter A, Get(ScriptParameter)=2, Parameter B)")

 

rather than

 

Evaluate ( Case(Get(ScriptParameter)=1, Parameter A, Get(ScriptParameter)=2, Parameter B) )

Link to comment
Share on other sites

I thought the description in the application help for the Evaluate() function covered this pretty well. But if it helps, you can also define a custom function to do the messy part of this. The CF I used was this:

 

GetParameter( ParameterName ) = 
// This system passes parameters to scripts in the form of "Parameter1 = \"Param1\"; Parameter2 = \"Param2\"".
// This function will extract the named parameter from the full script parameter, so that calling, when the above
// was passed, GetParameter( "Parameter1" ), will return "Param1".

Evaluate( "Let ( [ " & Get( scriptParameter ) & " ]; " & ParameterName & " )" )

To send the values, you then must use the syntax specified. In the Script Parameter box, insert the parameter names and values in the format:

 

"LastName = \"" & NameLast & "\"; FirstName = \"" & NameFirst & "\""

 

Where NameLast and NameFirst are field names. Then in the scripts, use the CF to retrieve the values:

 

GetParameter("LastName")

 

 

There are other similar CFs to do this, but this seems easy enough.

Link to comment
Share on other sites

Thank you very much people.

 

I got three different takes on Evaluate and did a bit of experimenting with it myself. I think I've got my head round it now. I like the fact that someone here will present a use or method I probably wouldn't have stumbled across let alone thought of.

 

Result. (yes that was meant to be a joke).

Link to comment
Share on other sites

 Share



×
×
  • Create New...

Important Information

Terms of Use