PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 2024 → Using CALLDLL32 in WD[5.5] converting from VB
Using CALLDLL32 in WD[5.5] converting from VB
Iniciado por Marco Antonio - Brasil, abr., 15 2004 1:25 AM - 4 respostas
Publicado em abril, 15 2004 - 1:25 AM
Hi,
I`m trying to capture 3 bytes of status that a POS printer serial.
This code is in VISUAL BASIC and works correct. I receive as return 0, 128, 0 = no paper (I´m simulating this condition)
look at
RetornoFuncao As String
valorretorno as string
Dim ACK As Integer
Dim ST1 As Integer
Dim ST2 As Integer
// Epson_FI_ReturnPrint() is a function of a EPSONFI.DLL opened before
RetornoStatus = Epson_FI_ReturnPrint(ACK, ST1, ST2)
ValorRetorno = Str(ACK) & "," & Str(ST1) & "," & Str(ST2)

valor retorno = "0" , "128", "0"
If (ST1 >= 128) Then
StringRetorno = "End of paper"
End If
NOW, In try to convert to WD5.5
ACT IS short INT
ST1 IS short INT
ST2 IS short INT
VRET IS INT = CALLDLL32("EPSONFIDLL","ReturnStatus",&ACT, &ST1, &ST2)
IN THIS CASE, the return is 0, 0, 0 in the same condiction
I TRIE USE ASCIIZ, FIXED, INT, LONG INT, with no results,
if I use ACT without & , I have fatal error

Can You Help me again
Thanks a Lot
Marco
Publicado em abril, 15 2004 - 2:48 AM
Try these:
ACT is fixed string on 10
ST1 is fixed string on 10
ST2 is fixed string on 10
Regs,
King
Hi,
I`m trying to capture 3 bytes of status that a POS printer serial.
This code is in VISUAL BASIC and works correct. I receive as return 0, 128, 0 = no paper (I´m simulating this condition)
look at
RetornoFuncao As String
valorretorno as string
Dim ACK As Integer
Dim ST1 As Integer
Dim ST2 As Integer
// Epson_FI_ReturnPrint() is a function of a EPSONFI.DLL opened before
RetornoStatus = Epson_FI_ReturnPrint(ACK, ST1, ST2)
ValorRetorno = Str(ACK) & "," & Str(ST1) & "," & Str(ST2)

valor retorno = "0" , "128", "0"
If (ST1 >= 128) Then
StringRetorno = "End of paper"
End If
NOW, In try to convert to WD5.5
ACT IS short INT
ST1 IS short INT
ST2 IS short INT
VRET IS INT = CALLDLL32("EPSONFIDLL","ReturnStatus",&ACT, &ST1, &ST2)
IN THIS CASE, the return is 0, 0, 0 in the same condiction
I TRIE USE ASCIIZ, FIXED, INT, LONG INT, with no results,
if I use ACT without & , I have fatal error

Can You Help me again
Thanks a Lot
Marco
Publicado em abril, 15 2004 - 3:32 AM
Try these:
ACT is fixed string on 10
ST1 is fixed string on 10
ST2 is fixed string on 10
Regs,
King

Thanks King, but, doesn´t solve
the return was
act = "(0)(0)(0)(0)(0)(0)(0)(0)(0)(0)"
the return expect is a integer like 128 (for no paper), etc.
in VB works.
I new ideas are welcome
thanks
Marco
Publicado em abril, 15 2004 - 12:14 PM
Hi Marco,
NOW, In try to convert to WD5.5
ACT IS short INT
ST1 IS short INT
ST2 IS short INT
VRET IS INT = CALLDLL32("EPSONFIDLL","ReturnStatus",&ACT, &ST1, &ST2)

[...]
How is the "ReturnStatus" function declared in VB ?, got some docu?
(The Epson_FI_ReturnPrint(ack,st1,st) looks like some VB procedure)
Well, my first try would be:

***
ack,st1,st2, vret are int
liDllInst is long int
liDllInst=loaddll("epsonfi.dll")
if liDllInst > 0
vret=calldll32("epsonfi.dll","ReturnStatus",&ack,&st1,&st2)
info(ack+" "+st1+" "+st2)
freedll(liDllInst)
end
***
Peter


http://www.xs4all.nl/~petervu
Publicado em abril, 15 2004 - 3:19 PM
Hi Peter,
this is a complete example in VB. The DLL was write in C+
I m using others functions of dll which doesn´t need to check bytes of return
like
vret is int = calldll32("EPSONFI.DLL","PRINTER_TURN_ON")
IF VRET > 0 THEN
CHECKERROR()
ELSE
CONTINUES...
END
Public Function VerificaRetornoImpressora(Label As String, RetornoFuncao As String, TituloJanela As String)
Dim ACK As Integer
Dim ST1 As Integer
Dim ST2 As Integer
Dim RetornaMensagem As Integer
Dim StringRetorno As String
Dim ValorRetorno As String
Dim RetornoStatus As Integer
Dim Mensagem As String

If Retorno = 0 Then
MsgBox "comunication error.", vbOKOnly + vbCritical, TituloJanela
Exit Function

ElseIf Retorno = 1 Then
RetornoStatus = Epson_FI_RetornoImpressora(ACK, ST1, ST2)
ValorRetorno = Str(ACK) & "," & Str(ST1) & "," & Str(ST2)

If Label <> "" And RetornoFuncao <> "" Then
RetornaMensagem = 1
End If

If ACK = 21 Then
MsgBox "Status da Impressora: 21" & vbCr & vbLf & "Comando não executado", vbOKOnly + vbInformation, TituloJanela
Exit Function
End If

If (ST1 <> 0 Or ST2 <> 0) Then
If (ST1 >= 128) Then
StringRetorno = "end of paper" & vbCr
ST1 = ST1 - 128
End If
....
with VB the results is 0, 128, 0 in integer (for no paper condition)
iN WD the results is 0, 0, 0
others tips will be welcome
Thanks a Lot
Marco