SteveS
October 3rd, 2001, 11:30 AM
I have created an ActiveX control in VisualC++ and one function is set to return "BOOL". I have created my object on my VBScript page and I would like to examine the return code of this value.
First off, the control was written in VC++ and returns a C++ BOOL value. BOOL defines FALSE as 0 and TRUE as 1. The VBScript Boolean data values are different: False is 0 and True is -1. Is the VBScript engine smart enough to do the conversion for me?
Second problem, when I set a variable equal to my control's return value, it seems to screw up the behavior of the rest of the code. For example:
Dim bRet, MyText
:
:
bRet = MyControl.ParseString("Hello World")
MyText = MyControl.GetFirstWord()
' MyText is empty and bRet is always false no matter
' whether or not ParseString() actually succeeded
:
:
I would expect bRet to equal False if the function fails or something else if it succeeded, but no matter what data I put into that function bRet will equal 0.
In the condition where that function really had succeeded, the next function should have set MyText to "Hello" but instead it creates an empty string.
If, however, I do not attempt to examine the return value of ParseString(), GetFirstWord() will be "HELLO".
Dim MyText
:
:
MyControl.ParseString("Hello World")
MyText = MyControl.GetFirstWord()
' MyText is "Hello" as expected
:
:
Why???
First off, the control was written in VC++ and returns a C++ BOOL value. BOOL defines FALSE as 0 and TRUE as 1. The VBScript Boolean data values are different: False is 0 and True is -1. Is the VBScript engine smart enough to do the conversion for me?
Second problem, when I set a variable equal to my control's return value, it seems to screw up the behavior of the rest of the code. For example:
Dim bRet, MyText
:
:
bRet = MyControl.ParseString("Hello World")
MyText = MyControl.GetFirstWord()
' MyText is empty and bRet is always false no matter
' whether or not ParseString() actually succeeded
:
:
I would expect bRet to equal False if the function fails or something else if it succeeded, but no matter what data I put into that function bRet will equal 0.
In the condition where that function really had succeeded, the next function should have set MyText to "Hello" but instead it creates an empty string.
If, however, I do not attempt to examine the return value of ParseString(), GetFirstWord() will be "HELLO".
Dim MyText
:
:
MyControl.ParseString("Hello World")
MyText = MyControl.GetFirstWord()
' MyText is "Hello" as expected
:
:
Why???