''#define UNICODE
'' **************************************************************************
'' RunScript:
''   Run a script using the MSScriptControl. Optionally return a result.
''
sub RunScript ( byval szRetIdentifier as STRING, _
			    byval pResult as LONG, _
 			    byval szScript as STRING, _
 			    byval szLanguage as STRING )
 
CreateObject( "MSScriptControl.ScriptControl")

.Language = %T", szLanguage
.AllowUI = %b", TRUE
.UseSafeSubset = %b", FALSE)
   20 
if( pResult = FALSE ) then
	dhCallMethod( scrCtl, ".Eval(%T)", szScript )
else
	dhGetValue( szRetIdentifier, pResult, scrCtl, ".Eval(%T)", szScript )
end if
SAFE_RELEASE( scrCtl )
end sub




'test code
dim nResult as integer 

'' VBScript sample
RunScript( NULL, NULL, !"MsgBox(\"This is a VBScript test.\" & vbcrlf & \"It worked!\",64 Or 3)", "VBScript" )

'' JScript sample
RunScript( "%d", @nResult, "Math.round(Math.pow(5, 2) * Math.PI)", "JScript" )
print "Result ="; nResult
print "Press any key to exit..."
sleep
