
Having problems running scripts and hosting.
I'm writing an object to act as a scripting host and trying to test it
out. Currently I don't have a context (item names) and am running the
scripts in the scripting engine's global context.
I think I'm successfully hosting and what I'd like to do is initially
use scripts as simple math functions, that do some calculations and
return a value.
Everything looks good until I actually run a script (ParseScriptText).
It seems no matter what kind of script I pass to the engine I get an
error (OnScriptError) that says "Invalid Character".
My scripts are simple...for example I've tried passing...as a test.
Function Celsius(fDegrees)
Celsius = (fDegrees - 32) * 5 / 9
End Function
x = Celsius(31)
I've also tried just passing
Celsius = (fDegrees - 32) * 5 / 9
What I don't fully understand is my results. How does the script "return
results" from the call to ParseScriptText.
my call looks like
HRESULT hr = m_Parser->ParseScriptText(theScript, NULL, NULL,
NULL, 0, 0, 0L, &pvarResult, NULL);
So If I want to write a simple math function, pass it in theScript
variable and get the results back, what does the script look like?
All I get are errors from the scripting engine.
I am telling it to use the VBScript engine when I call CoCreateInstance.
My only other clue is that I don't fully understand dwFlags and the
difference.
dwFlags
[in] Flags associated with the scriptlet. Can be a combination of
these values:
SCRIPTTEXT_ISEXPRESSION If the distinction between a computational
expression and a statement is important but syntactically ambiguous in
the script language, this flag specifies that the scriptlet is to be
interpreted as an expression, rather than as a statement or list of
statements. By default, statements are assumed unless the correct choice
can be determined from the syntax of the scriptlet text.
SCRIPTTEXT_ISPERSISTENT Indicates that the code added during this call
should be saved if the scripting engine is saved (for example, through a
call to IPersist*::Save), or if the scripting engine is reset by way of a
transition back to the initialized state.
SCRIPTTEXT_ISVISIBLE Indicates that the script text should be visible
(and, therefore, callable by name) as a global method in the name space
of the script.
To make this long story short, I think I'm correctly hosting the
scripting engine (I am getting script errors) but I don't know what
"form" a script takes when there is no context. I just want it to return
values right now.
thanks
mike