Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7006 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I'm trying to figure out why I can't use the Evaluate () function in a custom function (at least in the way I want). Here's what's going on...

I downloaded a sample file from http://www.databasepros.com (created by Reed Wycuff) of this nifty little ChangeLog2, which shows how to use a single auto-enter calc to create a change log. While looking at the formula, I thought it would be really cool to make it into a more modular Custom Function. I took the original formula of:

[color:blue]Let([x = Evaluate("Get(ActiveFieldContents)";[[color:red]Text;Number;Date;Time[color:blue]]);y = "[color:red]Text:Number:Date:Time[color:blue]"];(

Case(

PatternCount(y;Get(ActiveFieldName));

"- " &

GetAsText(Get(CurrentDate)) & " | " &

GetAsText(Get(CurrentTime)) & " | " &

Get(AccountName) & " | " &

Get(ActiveFieldName) & " = " &

x &

Case(not IsEmpty(Log);"¶") & Log

)))

and tried to substitute the actual names of the fields (shown above as Text;Number;Date;Time)with Function Parameters (field1;field2 ) I defined in the Custom Function dialog, as you'll see in the following:

[color:blue]Let ( [x = Evaluate("Get(ActiveFieldContents)";[[color:red]field1;field2[color:blue]]);y = Substitute ( "[color:red]field1;field2[color:blue]" ; ";" ; ":")];

Case(

PatternCount(y;Get(ActiveFieldName));

"- " &

GetAsText(Get(CurrentDate)) & " | " &

GetAsText(Get(CurrentTime)) & " | " &

Get(AccountName) & " | " &

Get(ActiveFieldName) & " = " &

x &

Case(not IsEmpty(logField);"¶") & logField

))

[color:black]I figured that in doing it this way there'd be no chance of one field name occurrence not jiving with the other occurrence in the formula, thus making setup and maintenance of the log really simple.

Thanks in advance for any suggestions offered!

Posted

No takers on this one??? :)

Maybe I gave too much info in my original post so let's try this...

Try to create a Custom Function with the following 3 parameters defined:

Whatever

FieldA

FieldB

Now write the Custom Function as:

Evaluate ( Whatever ; [FieldA;FieldB])

When I've written it as shown above I get an error message saying "A number, text constant, field name or "(" is expected here." and "FieldA" is indicated by hiliting. Conversely, if I write the function as:

Evaluate ( Whatever; [field1 ; field2] )

i.e. I leave the Evaluate functions default parameters of [field1 ; field2], I get the warning message "The specified parameter cannot be found". This has led me to believe that one of the parameters I've defined can be used.

After going round and round with this I'm to the point of saying, "Hey Moe, hey Larry...".

Any insight into handling this dilemna is greatly appreciated!

Posted

I believe this is a result of Filemaker not always making a clear distinction between refering to a field name vs. refering to the field contents.

Evaluate() is a good example - the optional field list is a list of field NAMES. Properly, the syntax should have been Evaluate ( "expression" ; [ "FieldNameA" ; "FieldNameB" ] ).

See if using GetField() might help here.

Posted

Hi comment

but this simple calc:

Evaluate ( whatever ; [ fieldA; fieldB ])

evaluates !

Without writhing "fieldA" and "fieldB" !

(If fieldA contains 2 and fieldB contains 3, whatever contains fieldA*fieldB the calc gives: 6)

So I think that Kent_S is right on :)

Posted

I don't think we are on the same page.

Suppose you have a text field called Trigger, and a stored calculation field =

Evaluate ( "Get ( CurrentTime )" ; Trigger )

The calc field is going to update every time Trigger is modified.

Now try to make a custom function that will allow the user to enter the formula and the triggering field as parameters.

Something like:

Whatever ( formula ; triggerField ):)

Evaluate ( formula ; triggerField )

But Filemaker will not let you create a custom function like this - because "triggerField" is not a field name.

Posted

you said:

Whatever ( formula ; triggerField ):)

Evaluate ( formula ; triggerField )

But Filemaker will not let you create a custom function like this - because "triggerField" is not a field name

It is for this that I was thinking that the guy is right! (isn't this post title:Can't use Evaluate () in Custom Function?)

If FM do not allow, this function can't be used.

Or do you know a way to pass it a valid field name?

This topic is 7006 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.