Detect-and-run a method in a Script Host using Java and FESI

J

Jay

Hi, Everybody:

I have a script host that implemented in Java and using FESI to run
JavaScript. The JavaScript files are separated into different files and
putting together at run or load time. Every time I have to manually to
make sure that a function referenced in one file is defined in another
so my host won't crash due to exception. I have been trying to put in a
detect-and-execute logic in my code for some time but with no real
success. This mainly due to FESI limitation. I believe only JavaScript
1.1 is supported. I have tried eval with try-catch but FESI won't allow
the key word "try" and "catch". I wonder if anybody in this group have
come across the similar problem? Any pointer would be very appreciated.

Thanks,

-Jay
 
M

Martin Honnen

Jay said:
I have tried eval with try-catch but FESI won't allow
the key word "try" and "catch".

Using
if (typeof someName != 'undefined')
or
if (typeof someName == 'function')
should work even if try/catch is not supported.

And you might consider to switch to the Mozilla Rhino engine instead of
FESI, it is a Java implementation as well but up to date to implement
JavaScript 1.5/ECMAScript edition 3 including try/catch.
 
J

Jay

Martin,

Thanks a lot for the pointers. Will let you know my findings.

Thanks again,

-Jay
 
J

Jay

Martin,

The typeof worked.
As side note to your response, your suggested code won't escape the
compilier check if it's run under JScript.Net and use MicroSoft VSA
engine as host. I happen to have two engines run side-by-side and one
is worked the other giving compilier error.

The Mozilla Rhino you mentioned sure gives me an option to substitute
the FESI.

Thanks again for your response,

-Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top