Page 1 of 1
Activex difference between FWH/XHB
Posted: Wed Jun 07, 2006 1:08 am
by Adolfo
Antonio
This piece of code works ok in Xhb.com
Comando:=Chr(2) + Chr(1)
Ef:AddDataField(Comando)
Extension:=VtArrayWrapper(VT_UI1,(CHR(0) + CHR(0) + CHR(0) + CHR(0)))
Ef:AddDataField( Extension )
Ef:SendCommand()
It sends 13 bits to com1, like the OCX is intended to do..
--> Length 13: 02 D5 1B 02 01 1C 00 00 03 30 31 31 34
But....
Comando:=Chr(2) + Chr(1)
Ef:DO("AddDataField",COMANDO)
Extension:=VtArrayWrapper(VT_UI1,(CHR(0) + CHR(0) + CHR(0) + CHR(0)))
Ef:DO("AddDataField", Extension)
Ef:Do("SendCommand")
... sends only 11
--> Length 11: 02 D5 1B 02 01 1C 03 30 31 31 34
My definition of the Activex is like this...
Ef:=TActiveX():New( , "EpsonFPHostControlX.EpsonFPHostControl")
Ef:nWidth = 0
Ef:nHeight = 0
Ef:Do("OpenPort")
Quite simple, in Xhb Works Ok but I can't make it work in FWH only...
Any help will be appreciated.
Posted: Wed Jun 07, 2006 11:40 am
by Antonio Linares
Adolfo,
Where are these bytes defined ?
> 02 D5 1B 02 01 1C 00 00 03 30 31 31 34
It looks as the two in between zeros are the missing ones.
Posted: Wed Jun 07, 2006 12:47 pm
by Adolfo
Antonio.
This is just an example, because in the real string, the last 3 groups of bytes are the validation bytes, which change with each string sent to the port.
--> Length 13: 02 D5 1B 02 01 1C -> 00 00 <- 03 30 31 31 34
--> Length 11: 02 D5 1B 02 01 1C -> <- 03 30 31 31 34
Is the problem a diferent way in which xhb and FWH send the parameters to the Method inside the activex class ?
All the other properties, errors messages are recovered without problems, and the only one which is still bothering me is this one.
Next step is to control the Events, but I've seen some examples which I'm gonna look at.
Thanks in advance
Posted: Wed Jun 07, 2006 1:20 pm
by Antonio Linares
Adolfo,
Please try this code:
MsgInfo( Len( WideToAnsi( AnsiToWide( <cData> ) ) ) == Len( <cData> ) )
where <cData> is the bytes string you send.
Posted: Wed Jun 07, 2006 1:35 pm
by Adolfo
Antonio Linares wrote:Adolfo,
Please try this code:
MsgInfo( Len( WideToAnsi( AnsiToWide( <cData> ) ) ) == Len( <cData> ) )
where <cData> is the bytes string you send.
With this code
Comando:=chr(2) + Chr(1)
lRes:=Ef:DO("AddDataField",Comando)
MsgInfo( Len( WideToAnsi( AnsiToWide( Comando ) ) ) == Len( Comando ) )
........ The result is .T.
Extension:=VtArrayWrapper(VT_UI1,(CHR(0) + CHR(0) + CHR(0) + CHR(0)))
Ef:DO("AddDataField", Extension)
Ef:Do("SendCommand")
MsgInfo( Len( WideToAnsi( AnsiToWide( Extension ) ) ) == Len( Extension ) )
............. I get this error..
Unrecoverable error 9023
hb_xgrab requested to allocate zero bytes
What does it mean ?
Posted: Wed Jun 07, 2006 5:36 pm
by Antonio Linares
Adolfo,
Where are the docs or samples for VtArrayWrapper() ?
Posted: Wed Jun 07, 2006 7:08 pm
by Adolfo
Antonio Linares wrote:Adolfo,
Where are the docs or samples for VtArrayWrapper() ?
Antonio
This is what I found in the "what's New" of Xharbour.com February Release
# Renamed class VT to VTWrapper, and VTArray to VTArrayWrapper.
# Added [] and "FOR EACH" operator overloading for VTArrayWrapper().
# Added auto wrapping of non VT_VARIANT arrays with VTarrayWrapper() class.
Nevertheless, If I don't Use VtArrayWrapper(), and try to do this... in FWH
Extension:=Chr(0) + Chr(0)
Ef:DO("AddDataField",Extension)
I get the same problem... no Bytes added to the string sent to the Com port
Thanks..
Posted: Wed Jun 07, 2006 9:38 pm
by Antonio Linares
Adolfo,
Please try this again without using VT... :
MsgInfo( Len( WideToAnsi( AnsiToWide( Extension ) ) ) == Len( Extension ) )
Posted: Thu Jun 08, 2006 12:31 am
by Adolfo
Antonio Linares wrote:Adolfo,
Please try this again without using VT... :
MsgInfo( Len( WideToAnsi( AnsiToWide( Extension ) ) ) == Len( Extension ) )
Here is my code and the results
Extension:=CHR(0) + CHR(0)
Alert(len(Extension)) -> 2
Alert(Len(AnsiToWide( Extension ))) -> 1
MsgInfo( Len( WideToAnsi(AnsiToWide(Extension))) == Len(Extension)) -> .F.
Now loking in some other stuff I have to do with the OCX I realize that I'll need to use CHR(0) + Chr(3), not only Zeroes but mixed with values between 1-15
The problem is that I need It to use with Both xHarbour Compilers, for 2 very big and different projects, that's why the solution found in xHb.com is not suitable for xHarbour.org, so I need it to be done with FWH.
Thanks again for your time
Posted: Thu Jun 08, 2006 6:27 am
by Antonio Linares
Adolfo,
Thats what I was thinking, that FWH AnsiToWide() is not properly managing the zeroes:
Extension:=CHR(0) + CHR(0)
Alert(len(Extension)) -> 2
Alert(Len(AnsiToWide( Extension ))) -> 1
We are going to review it.
Posted: Thu Jun 08, 2006 6:44 am
by Antonio Linares
Adolfo,
We are emailing you a modified FiveHC.lib. Please try it. Thanks,
Posted: Thu Jun 08, 2006 12:49 pm
by Adolfo
Antonio
Thanks a lot...
I'm Gonna try it, I'll send you any result I'll get
Adolfo
Posted: Thu Jun 08, 2006 1:46 pm
by Adolfo
Antonio...
I replace Fivehc.lib with the one you sent me.
Please Try This..... Either with xHarbour/xHarbour.com
//-----------------------------------------------------------------------------------
Function Main()
Local Extension
Extension:=chr(2) + Chr(1)
MsgStop(len(Extension),"Extension 1 Len()")
MsgStop(Len(AnsiToWide( Extension )),"Extension 1 Len(AnsiToWide)")
MsgInfo( Len( WideToAnsi(AnsiToWide(Extension))) == Len(Extension))
Extension:=chr(0) + Chr(1)
MsgStop(len(Extension),"Extension 2 Len()")
MsgStop(Len(AnsiToWide( Extension )),"Extension 2 Len(AnsiToWide)")
MsgInfo( Len( WideToAnsi(AnsiToWide(Extension))) == Len(Extension))
Extension:=Chr(0) + Chr(0)
MsgStop(len(Extension),"Extension 3 Len()")
MsgStop(Len(AnsiToWide( Extension )),"Extension 3 Len(AnsiToWide)" )
MsgInfo( Len( WideToAnsi(AnsiToWide(Extension))) == Len(Extension))
Return Nil
//----------------------------------------------------
My results for Chr(2) + Chr(1)
Len() -> 2
Len(AnsiToWide(ext)) -> 5
= .T.
My results for Chr(0) + Chr(1)
Len() -> 2
Len(AnsiToWide(ext)) -> 1
= .F.
My results for Chr(0) + Chr(0)
Len() -> 2
Len(AnsiToWide(ext)) -> 1
= .F.
The Problems still remains with Chr(0)
Posted: Thu Jun 08, 2006 2:08 pm
by Antonio Linares
Adolfo,
Please try it with Harbour (not xHarbour) as xharbour provides another AnsiToWide() that probably is getting used instead of FWH's one.