Re: VBScript OCX receive and supply a safeArray of type VT_UI1- problem

"R.Wieser" <[email protected]>
Newsgroups alt.comp.os.windows-xp,alt.windows7.general,comp.os.ms-windows.programmer.win32
Organization A noiseless patient Spider
Message-ID <[email protected]>
Newyana2,

>>> If you declare Dim A2()
>>
>> Which I have not done and, in the current case, have no intention to.
>
>   You have no choice in VBScript.

Guess again.

> Or you declare A1 and use that to receive an array variable.

Bingo !

And that is what I tried to tell you the whole time : a OCX-base method 
which returns a SafeArray (of type VT_UI1), which than get stored (by 
VBScript) into a Variant.

So, I *do* have a choice.

>>> I assumed you were working in VB6, using VB6 strings.
>>
>> Whut ?  I specifically mentioned VBScript in the subjectline and the 
>> first
>> post, as well as thruout my replies ...
>>
>     I meant the language you're writing the OCX in.

I realized too late that that might have been what you ment.

But no, I'm using Assembly.  And yes, that means I get to see a *lot* of the 
inner workings of programs.

> You're not writing the OCX is VBS, right? (Please tell me that you didn't 
> take that on as an interesting challenge. :)

wellll....  I would probably try (just to see if I could), if I would not 
know that due to the lack of build-in features VBScript makes that 
impossible.

>   If you write the OCX in VB then the VB function can return
> a string:
>
> Function GetBlah() as Variant
>   s = "blahblahblah"
>   GetBlah = "CVar(s)
> End Function

I have absolutily zero idea what "cvar()" does.  But if it returns a BSTR 
than I've already mentioned the problem with that - as well as ofcourse that 
it would double the needed space to store the origional array of bytes.  A 
multiplication which I try to keep away from.

> Otherwise you'll ned to explicitly convert each array
> member to variant:
>
> Function GetBytes() As Variant
>   Dim A1(2) as variant
>   A1(0) = cvar(120)
>   A1(1) = CVar(12)
>   A1(2) = cvar(33)
>   GetBytes = A1
> End Function

And multiplying the needed storage space by 16 ?  Yeah, no.

>>> A safearray is a variant. The data may be other datatypes.
>>
>> No, it isn't.  What you are referring to is a Variant which contains (a
>> pointer to) a SafeArray.
>>
>   An array is a variant. Yes, it's a pointer-type variable.

Nope.   How many times do I have to mention that I'm returning a SafeArray 
of type VT_UI1 ?   That is *NOT* a Variant, not from the outside, not from 
the inside.

>>>   For i = 0 to UBound(ArrayThatsAString)
>>>    Select Case i
>>
>> Are you trying to pull my leg ?   The only thing there you are using
>> "ArrayThatsAString" for is to get its length.
>>
>  Sorry. Maybe this went over your head.

No, it didn't.

> My example was showing how data in an array is structured.

No, you didn't.  You just counted up from Zero upto a value equal to the 
length of the string inside teh 'ArrayThatsAString' variable, wrote comments 
as if the count would represent a character - and than "Do This" and "Do 
That" when it reached a certain count.

You have *NOWHERE* accessed that "array that is a string" - other than to 
get its length.

> It was a sample of VB code, not VBS.

:-) I do not need to know the fine points of either language to see that you 
have create a simple loop, which doesn't even do anything when counting from 
0 upto 31.

>> In VBS you cannot access memory directly, ever.
>
> Yes. As I said in the line you snipped but addressed:
>
> "You can't do anything like that in VBS because each array member is
> always a variant and there's no direct access to memory addresses"

You should really drop your hangup on arrays and variants you know.  It gets 
tedious.

Also, what have variants to do with accessing memory ?  They can be used 
store the result of such a memory access, but thats all.

And that is what I tried to make clear : Your arrays and Variants mentioning 
there is nothing more than a red herring.

> I'm going to give you the benefit of the doubt and assume that you
> read my post hastily and didn't follow the logic, but it sounds like 
> you're just looking to argue again.

Seeing how you have ignored every explanation to how I stored a VT_UI1 
SafeArray into VBScript and kept hammering that 'all arrays are variants' 
and that 'a SafeArray is a variant too' I don't think you are the one who 
should be talking about "benefit of the doubt".

To be crude about it, I'm currently doubting either your knowledge or your 
intentions.

Regards,
Rudy Wieser
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.