BookmarkSubscribe
Choose Language Hide Translation Bar
wma1125
Community Trekker

how to bypass parse("a+b)") error?

how to by pass parse("a+b)")  error? I've tried Try() but it didn't work..

0 Kudos
4 REPLIES 4
txnelson
Super User

Re: how to bypass parse("a+b)") error?

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?

Jim
Highlighted
Craige_Hales
Staff (Retired)

Re: how to bypass parse("a+b)") error?

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.

Craige
msharp
Super User

Re: how to bypass parse("a+b)") error?

Thanks for this tip, this sure will help keeping the log file clean.

0 Kudos
wma1125
Community Trekker

Re: how to bypass parse("a+b)")  error?

thanks, Graige. I was trying to parse some formula from an excel table where users key in their formula. However, sometimes there are typos..

0 Kudos