Hello ,
I try to run the sample C:\masm32\COM\examples\Scripter\scripter.exe
exactly as it is in the masm32 package.
I push the big button "Run script" and the "MyScript.vbs" is loaded
The text of the original script is:

Dim MyVar, Input
MyVar = 0
MyVar = MyVar + 1
MyVar = MyVar + 1
MyVar = MyVar + 1
MyVar = MyVar + 1
MyVar = MsgBox ("MyVar is now " & MyVar, 65, "pssssssssst......")
Application.SetText = "Now you can set the text HERE by script alone."
Input = InputBox("Enter your name")
DO
Application.SetText = "You entered: " & CHR(13) & CHR(10) & Input
Input = InputBox("Now enter something else:")
IF Input = "" Then Exit Do
LOOP

********* The script display "MyVar is now 4" and that all. *********
********* Searching for what it didn't work , I found this.**********
The word "Application" is correctly initialised by
coinvoke pIAS, IActiveScript, AddNamedItem, ADDR wsApplication, SCRIPTITEM_ISVISIBLE
AT run ,the word is found by IActiveScriptSite_GetItemInfo BUT the proc SetText is never called.
An error occured in the script at:
IActiveScriptSite_OnScriptError PROC this_:DWORD, pase:DWORD
I try to have more explain on the error using that (My lines codes):
mov edx, pase
mov edx,
invoke (IActiveScriptError PTR).IActiveScriptError_GetSourceLineText,pase,addr phrase
******* This don't work anyway , no S_OK return ********
I try also to modify the script but no more results.
What can I do to make it work ?.I don't see what to do more.
Thanks for you answer ,ToutEnMasm
Posted on 2003-05-21 11:25:25 by ToutEnMasm
ToutEnMasm,

I'm at a loss to understand why it doesn't work for you. Obviously, it ran fine for me or I wouldn't have posted it.

All my tuts on COM are rather old now, new generations of the script engines, running on new platforms, are seemingly adding new complexities these simple examples don't handle.
Posted on 2003-05-21 22:12:41 by Ernie
ToutEnMasm,

possibly extent OnScriptError method a bit.

Here an example



OnScriptError PROC uses ebx __this this_:ptr CActiveScriptSite, pase:ptr IActiveScriptError

local bstr:BSTR
local dwESP:DWORD
local dwContext:DWORD
local dwLine:DWORD
local dwCharPos:DWORD
local ei:EXCEPINFO
local szText1[128]:byte
local szText2[128]:byte
local szText3[128]:byte

mov __this,this_

DebugOut "IActiveScriptSite::OnScriptError"

mov ebx,pase
mov szText1,0
mov szText2,0
mov szText3,0
invoke vf(ebx, IActiveScriptError, GetExceptionInfo), addr ei
.if (eax == S_OK)
.if (ei.bstrSource)
invoke WideCharToMultiByte, CP_ACP, 0, ei.bstrSource, -1, addr szText1, sizeof szText1, NULL, NULL
invoke SysFreeString, ei.bstrSource
.endif
.if (ei.bstrDescription)
invoke WideCharToMultiByte, CP_ACP, 0, ei.bstrDescription, -1, addr szText2, sizeof szText2, NULL, NULL
invoke SysFreeString, ei.bstrDescription
.endif
invoke printf, CStr("OnScriptError: error %X, %s - %s"), ei.scode, addr szText1, addr szText2
.endif
invoke vf(ebx, IActiveScriptError, GetSourceLineText), addr bstr
.if (eax == S_OK)
invoke WideCharToMultiByte, CP_ACP, 0, bstr, -1, addr szText3, sizeof szText3, NULL, NULL
invoke printf, CStr("OnScriptError: %s"), addr szText3
invoke SysFreeString, bstr
.endif
invoke vf(ebx, IActiveScriptError, GetSourcePosition), addr dwContext, addr dwLine, addr dwCharPos


Japheth
Posted on 2003-05-22 02:04:23 by japheth
ToutEnMasm,

Ive taken a closer look at this example. The main problem in my eyes is that this colib stuff works only with registered type libraries, but there is no code and not even a hint of how to register the type information supplied. Executables sometimes self-register with a command line argument, but this code isnt implemented. But you may for example use COMView to register. Just start it, select option "Load TypeLib", search for ScriptText.tlb, press ok and then press button "Register type library".

Other potential problems of this example are:

1. Missing "terminating" zero byte for the script text. I would suggest to change the HeapAlloc in LoadScript to

invoke HeapAlloc, hHeap, HEAP_ZERO_MEMORY, eax

2. EBX is used in window proc without being saved previously

3. in method GetItemInfo is a call to method AddRef, which doesnt return a HRESULT, and EAX isnt set to S_OK after the call. I would suggest to insert that.

If you get the feeling that this example is a bit "unfinished" yet, your possibly right :) .

Japheth
Posted on 2003-05-23 02:06:11 by japheth