Page 1 of 1

Posted: Wed Jan 30, 2002 8:35 pm
by BackupUser
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

Posted: Wed Jan 30, 2002 9:06 pm
by BackupUser
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.

Posted: Wed Jan 30, 2002 9:55 pm
by BackupUser
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

Posted: Thu Jan 31, 2002 5:50 am
by BackupUser
Restored from previous forum. Originally posted by Kanati.

Thanks. Got it. Now to create something useful. :)

Kanati