Discussion:
Embeddded Script engine, two files loaded - line # problem (error message)
(too old to reply)
R.Wieser
2014-02-10 16:58:45 UTC
Permalink
Hello All,

I've been loading two script files into a VBScript engine that I've embedded
into a program of mine, and now have a problem with the error callback. Or,
to be more specific, the line # mentioned as provided by the error callback.

The problem is that the two scripts -- the first is a somewhat fixed
"header" file (containing a number of constant definitions) and the second a
user-provided one, the actual script -- seem to be regarded as a single, big
script, causing an error-callbacks line # into the second, users script to
be offset by the ammount of lines in the first, header file. And will
ofcourse confuse the user (which needs to have no knowledge about or be
bothered by the header file). :-\

My question: Is there a way to compartimentalize those two scripts in the
scripting engine in such a way that the error-callback will be able to
display the correct line # of the error in either scriptblock, presumably
together with some kind of indication of in which scriptblock it happened.

Preferrably the solution would be generic (work for any number of loaded
files).

Regards,
Rudy Wieser
R.Wieser
2014-02-13 11:54:12 UTC
Permalink
Post by R.Wieser
My question: Is there a way to compartimentalize those two scripts
in the scripting engine in such a way that the error-callback will be
able to display the correct line # of the error in either scriptblock,
presumably together with some kind of indication of in which
scriptblock it happened.
It turns out that this "compartimentalizing" is done by default. To descern
between the different loaded scripts a user defined value must be provided
as the IActiveScript::ParseScriptText dwSourceContextCookie argument, which
than gets returned in IActiveScriptError::GetSourcePosition pdwSourceContext
argument when an error occurs.

Regards,
Rudy Wieser

Loading...