News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Variables and pointers

Started by Adaz, August 22, 2006, 07:36:37 AM

Previous topic - Next topic

Adaz

Hi,

How can I use variables by pointers and by value?

If I have 2 variables, "A" and "B",
then in a CallDll() I want to send "A" by value, and "B" by pointer, how can I do that?

thanks

Ádáz

Hungary

kevin

#1
 You can't send a pointer to variable, it's not supported.   But since the pointer is just an 32bit address, you can store the required data in a bank and pass in that address variable (that points to the the bank) into the function.


PlayBASIC Code: [Select]
 // bank to store/passed pointers 
MyBank =NewBank(100)
BankAddress =GetBankPtr(MyBank)

// program stuff
A=45
B=50


// Dump the B value in to the bank
PokeInt BankAddress,B


// Call Dll
result= CallDll(1,"SomeFunction",A,BankAddress)


etc




Adaz


Ádáz

Hungary