Restored from previous forum. Originally posted by Kanati.
Now that we are able to pass info from Blitz TO a dll written with PB, the
only thing I cannot quite fathom is passing the data BACK to blitz. I was
getting illegal memory errors last night whilst playing with it and it would
crash the blitz program and the dll. Anyone have any examples of DLL code
that pass data back? I don't think I've seen any do that. They've all just
been "do a message box with data passed TO the dll" examples.
Thanks.
Kanati
Passing data BACK from a dll?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by mystik.
Hi Kanati,
I'm using this :
PUREBASIC
--------------------------------
ProcedureDLL bbdll (Out_Size.l, *BankOut.l, In_Size.l, *BankIn.l)
sBACK$="HELLO"
sTEST$=""
For a=1 To 5
sTEXT$=sTEXT$+Chr(PeekB(*BankIn+a))
PokeB(*BankOut+a,Asc(Mid(sBACK$,a,1)))
sTEST$=sTEST$+Chr(Asc(Mid(sBACK$,a,1)))
Next a
MessageRequester("I'm a DLL",sTEXT$ + ","+sTEST$, #PB_MessageRequester_Ok)
EndProcedure
BLITZ
-------------------------------------------
Graphics 800,600
In_Bank = CreateBank(10)
Out_Bank = CreateBank(10)
name$="Steve"
For i = 1 To 5
PokeByte in_bank,i,Asc(Mid$(name$,i,1))
Next
dll = CallDLL("purebasic.dll", "_bbdll", In_Bank, Out_Bank)
If dll 0 Then
Print "Call failed."
Else
Print "Call OK."
back$="":test$=""
For i = 1 To 5
back$=back$+Chr$(PeekByte(Out_Bank,i))
test$=test$+Str(PeekByte(Out_Bank,i)) + ","
Next
Print back$
Print test$
EndIf
FreeBank in_bank
FreeBank out_bank
WaitKey()
EndGraphics
End
Seems to work ok
Hope this helps
Steve.
Hi Kanati,
I'm using this :
PUREBASIC
--------------------------------
ProcedureDLL bbdll (Out_Size.l, *BankOut.l, In_Size.l, *BankIn.l)
sBACK$="HELLO"
sTEST$=""
For a=1 To 5
sTEXT$=sTEXT$+Chr(PeekB(*BankIn+a))
PokeB(*BankOut+a,Asc(Mid(sBACK$,a,1)))
sTEST$=sTEST$+Chr(Asc(Mid(sBACK$,a,1)))
Next a
MessageRequester("I'm a DLL",sTEXT$ + ","+sTEST$, #PB_MessageRequester_Ok)
EndProcedure
BLITZ
-------------------------------------------
Graphics 800,600
In_Bank = CreateBank(10)
Out_Bank = CreateBank(10)
name$="Steve"
For i = 1 To 5
PokeByte in_bank,i,Asc(Mid$(name$,i,1))
Next
dll = CallDLL("purebasic.dll", "_bbdll", In_Bank, Out_Bank)
If dll 0 Then
Print "Call failed."
Else
Print "Call OK."
back$="":test$=""
For i = 1 To 5
back$=back$+Chr$(PeekByte(Out_Bank,i))
test$=test$+Str(PeekByte(Out_Bank,i)) + ","
Next
Print back$
Print test$
EndIf
FreeBank in_bank
FreeBank out_bank
WaitKey()
EndGraphics
End
Seems to work ok
Hope this helps
Steve.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by morduun.
For another example, check http://www.blitzbasic.co.nz/cgi-bin/sho ... topic=5508 on the BB boards. The example I posted there, erm, goes both ways. *cough*
Three may keep a secret, if two of them are dead.
Edited by - morduun on 30 January 2002 21:55:58
For another example, check http://www.blitzbasic.co.nz/cgi-bin/sho ... topic=5508 on the BB boards. The example I posted there, erm, goes both ways. *cough*
Three may keep a secret, if two of them are dead.
Edited by - morduun on 30 January 2002 21:55:58
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm