how to by pass parse("a+b)") error? I've tried Try() but it didn't work..
Parsing the string "a+b)" will result in an error because of unbalanced parentheses. Can you provide more context on what you are attempting to do?
try this to keep the unwanted message out of the log:
exp = 0;
cap = 0;
cap = Log Capture( // capture anything written to log
exp = Try( //
Parse( "a+b)" ); //parse will throw AND write to log
,
42; // if the jsl fails to parse
)
);
Show( exp, cap ); // show what happened
exp = 42;
cap = " <<< this is the captured error message, you don't have to print it
Unexpected \!")\!". Perhaps there is a missing \!";\!" or \!",\!".
Line 1 Column 4: a+b►)
The remaining text that was ignored was
)";
It took me a couple of tries to get this right; the LogCapture must be outside of the try to get the results I think you want. Setting cap and exp to zero is not required, that was part of my debugging my JSL. They will both be set by the try and logCapture.
There are some other JSL functions with this behavior, and LogCapture will work for them too.
thanks, Graige. I was trying to parse some formula from an excel table where users key in their formula. However, sometimes there are typos..
Thanks for this tip, this sure will help keeping the log file clean.