forked from petrowsky/fmpfunctions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvar.eval.fmfn
30 lines (29 loc) · 1.27 KB
/
var.eval.fmfn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* =====================================================
* var.eval( contents )
*
* RETURNS: (bool) True or False based on proper evaluation
* DEPENDENCIES: none
* NOTES: Try to always use the List() function when passing multiple values into var.eval!
* =====================================================
*
* This custom function evaluates the contents passed as the
* variable declaration part of a Let function. Useful for
* defining global or locally scoped variables.
*
*/
Let( [
$$ERROR.VAR.EVAL = ""; // Reset the global error variable for evaluation
var.semicolons_exist = ( ValueCount ( contents ) = PatternCount ( contents ; ";¶" ) ) or ( ValueCount ( contents ) - 1 = PatternCount ( contents ; ";¶" ) );
var.contents = If ( not var.semicolons_exist ; Substitute ( contents ; ¶ ; ";¶") ; contents ); // Add semicolons if needed
var.trailing_semicolon = Right ( var.contents ; 1 ) = ";"; // Clean off the trailing semicolon if present
var.contents = If ( var.trailing_semicolon; Left ( var.contents ; Length( var.contents ) - 1 ); var.contents )
];
If (
Evaluate(
"Let ( [" & var.contents & "]; 1 )"
) = "?";
Let ( $$ERROR.VAR.EVAL = "EVAL ERROR¶-----¶" & var.contents; False );
True
)
)