Interesting. So you can retrieve the Pointer of the variable itself instead of the string in it. That's nice.
Code: Select all
Macro VarPtr(_Var_, _Pointer_)
EnableASM
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
lea rax, _Var_
mov _Pointer_, rax
CompilerElse
lea eax, _Var_
mov _Pointer_, eax
CompilerEndIf
DisableASM
EndMacro
Define text.s, *pText
text = "Hello World!"
VarPtr(text, *pText)
Debug "@text = " + StrU(@text, #PB_Quad)
Debug "*pText = " + StrU(*pText, #PB_Quad)
Debug "PeekI(*pText) = " + StrU(PeekI(*pText), #PB_Quad)
In the past I always created a structured string variable to make that happen, but of course that's ugly.
Code: Select all
Procedure.i MyFunction(*StringByRef.string)
*StringByRef\s + " I Like PureBasic ;)"
EndProcedure
Define text.String
text\s = "Hello World"
MyFunction(text)
Debug text\s
Works also with arrays, but is even uglier.
Code: Select all
Procedure.i MyFunction(*StringByRef.string)
*StringByRef\s + " I Like PureBasic ;)"
EndProcedure
Dim text.s(9)
text(5) = "Hello World"
MyFunction(@text() + SizeOf(String) * 5)
Debug text(5)
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.