osiris612mb Posted July 5, 2006 Posted July 5, 2006 I have a calc that uses the Evaluate() function but I am unsure as to why the syntax is the way it is... [color:brown]Evaluate ( "Get ( AccountName ) & " " & Get ( CurrentTimeStamp ) & " " & ...etc Why is it not [color:green]Evaluate ( Get ( AccountName ) & " " & Get ( CurrentTimeStamp ) & " " & I was told to use the former syntax but I am confused as to why there are the slashes there.
John Mark Osborne Posted July 5, 2006 Posted July 5, 2006 (edited) That's the beauty of Unicode. The Evaluate function needs a text parameter so you have to enclose the formula in quotes. Since your formula also includes quotes, you need to use double quotes to create a quote inside of an already quoted text string. However, when you exit the calculation dialog, FileMaker converts everything to Unicode and uses the slashes to designate the quote character. Edited July 5, 2006 by Guest
comment Posted July 5, 2006 Posted July 5, 2006 I am not sure this has to do with the Unicode. The Evaluate() function evaluates a text expression. If the text expression were supplied as Get (AccountName), the function would try to evaluate the actual account name (keep in mind that any expression enclosed in parentheses is evaluated first): Evaluate ( Get (AccountName) ) = Evaluate ( Admin ) = Admin = Error#102 - Field is missing unless you happen to have a field named Admin, in which case the function would return the contents of that field. OTOH: Evaluate ( "Get (AccountName)" ) = Get (AccountName) = "Admin" Here the result returned is the text string "Admin". The slashes are there to escape the quotes that are part of the text expression. Without them the text expression would end prematurely. A simpler way to write the same formula would be: Evaluate ( Quote ( Get ( AccountName ) & " " & Get ( CurrentTimeStamp ) ) ) Finally, it is not clear why you would need to use the Evaluate() function at all.
John Mark Osborne Posted July 5, 2006 Posted July 5, 2006 I always thought the advent of the escape character was the result of the Unicode adoption in FileMaker 7 but it looks like it is just something added to the calculation engine to allow for characters not to be evaluated as they normally would in a calculation. Hence, you can use the back slash to create a comment or display a quote character without having it evaluated as it normally would by the calculation engine. Since Devin doesn't display the entire calculation, I assume the reason he is using the Evaluate function is to allow for the optional second parameter(s) so the Evaluate function will update based on the changing of fields he decides should update the information. Notice there are no field references in his calculation. Depending on how he is implementing the calculation (Auto-Enter, Calculation Field, etc.) he might need the Evaluate function. Maybe he doesn't. If Devin tells us more about why he is using this formula, maybe we can figure this out.
comment Posted July 6, 2006 Posted July 6, 2006 I assume the reason he is using the Evaluate function is to allow for the optional second parameter(s) I assume the same. However, it is IMHO not a good practice. The Evaluate() function NEEDS the fields parameter BECAUSE the expression parameter must be text. When fields are referenced in the expression parameter, they will often be referenced in quoted form, i.e. Evaluate ( "SomeField" ). This means that modifying the contents of SomeField will NOT trigger a re-evaluation of the Evaluate() formula - since Filemaker sees only a text string, not a field reference. So including the fields parameter is a necessity, given the nature of the function. However, this does NOT mean that Evaluate() should be used solely as device to trigger a re-calc. The Evaluate() function is not like other functions: it needs to be evaluated twice. The first time, the calculation engine evaluates the Evaluate() function itself, and returns the text expression as a formula. The second time, the calculation engine evaluates the returned formula. So throwing in Evaluate() just for its triggering mechanism is inefficient. I believe that instead of: Evaluate ( Quote ( Get ( CurrentTimeStamp ) ) ; [ field1 ; field2 ] ) it's better (and more readable to boot) to use something like: Let ( trigger = field1 & field2 ; Get ( CurrentTimeStamp ) )
osiris612mb Posted July 6, 2006 Author Posted July 6, 2006 Sorry for not getting back to you guys sooner. I did not paste the whole calc thinking only the portion in question (the slashes) would be enough but now I realize otherwise. [color:green]Evaluate ( "Get ( AccountName ) & " " & Get ( CurrentTimeStamp ) & " " & WA & " " & Client_Code & " " & Date_Work_Done & " " & Work_Descr & " " & TEHours_worked & " " & Internal & " " & External & ¶ & Modified_Audit" ; [WA ; Client_Code ; External ; Date_Work_Done ; Work_Descr ; TEHours_worked] ) Basically we have an audit of whenever someone changes the, WA,Client_Code, External, Date_work_done, Work_descr and TEhoursworked fields, a new line is generated within the modified_audit field. Like I had mentioned, this is the way someone on here told me how to do it. If there is a better and easier way to write it up...please preach on!!
comment Posted July 6, 2006 Posted July 6, 2006 Like I said - an EASIER way to write the same thing: Evaluate ( Quote ( Get ( AccountName ) & " " & Get ( CurrentTimeStamp ) & " " & WA & " " & Client_Code & " " & Date_Work_Done & " " & Work_Descr & " " & TEHours_worked & " " & Internal & " " & External & ¶ & Modified_Audit ) ; [ WA ; Client_Code ; External ; Date_Work_Done ; Work_Descr ; TEHours_worked ] ) A BETTER way to get the same result: Let ( trigger = WA & Client_Code & External & Date_Work_Done & Work_Descr & TEHours_worked ; Get ( AccountName ) & " " & Get ( CurrentTimeStamp ) & " " & WA & " " & Client_Code & " " & Date_Work_Done & " " & Work_Descr & " " & TEHours_worked & " " & Internal & " " & External & ¶ & Modified_Audit )
Recommended Posts
This topic is 6714 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 accountSign in
Already have an account? Sign in here.
Sign In Now