I tried this but it did not work:
Code: Select all
Procedure.l GetErrorMessage(*AnErrorMessage.String)
*AnErrorMessage\s = "This is the message"
EndProcedure
S$ = " "
*Pointer.String = @S$
GetErrorMessage(*Pointer)
debug *Pointer\s

Code: Select all
Procedure.l GetErrorMessage(*AnErrorMessage.String)
*AnErrorMessage\s = "This is the message"
EndProcedure
S$ = " "
*Pointer.String = @S$
GetErrorMessage(*Pointer)
debug *Pointer\s
Code: Select all
Procedure.l GetErrorMessage(*AnErrorMessage.String)
*AnErrorMessage\s = "This is the message"
EndProcedure
Define StringByRef.String
StringByRef\s = ""
GetErrorMessage(StringByRef)
Debug StringByRef\s
Structure udtText
s.s
EndStructure
Define MyErrorText.udtText
GetErrorMessage(MyErrorText)
Debug MyErrorText\s

Code: Select all
Procedure.i GetErrorMessage(*AnErrorMessage.string)
*AnErrorMessage\s = "This is the message"
EndProcedure
Global *StrE.String = AllocateMemory(255*SizeOf(Character))
GetErrorMessage(*StrE)
Debug *StrE\s
FreeMemory(*strE)


Code: Select all
Procedure.i GetErrorMessage(*AnErrorMessage.string)
*AnErrorMessage\s = "This is the message"
EndProcedure
Debug "Size Of Type String: " + SizeOf(String)
Debug "Allocate Structure Of Type String"
Global *StrE.String = AllocateStructure(string)
Debug "Act Value of Pointer to String: " + PeekI(*StrE)
Debug "Call Function..."
GetErrorMessage(*StrE)
Debug "Act Value of Pointer to String: " + PeekI(*StrE)
Debug "PeekS String over Pointer: " + PeekS(PeekI(*StrE))
Debug "Default Output: " + *StrE\s
Debug "Free Structure: Is Freed String and Memory"
FreeStructure(*strE)
Code: Select all
Macro GetVarPtr(_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
Procedure.i GetErrorMessage(*AnErrorMessage.string)
*AnErrorMessage\s = "This is the message - " + *AnErrorMessage\s
EndProcedure
Define text.s, *pText
text = "Hello World"
GetVarPtr(text, *pText)
GetErrorMessage(*pText)
Debug text
Code: Select all
Procedure.l GetErrorMessage(*AnErrorMessage)
Protected *String.String = @*AnErrorMessage
*String\s = "This is the message"
EndProcedure
S$ = " "
GetErrorMessage(@S$)
Debug S$Code: Select all
Procedure.l GetErrorMessage(*AnErrorMessage)
Protected *String.String = @*AnErrorMessage
*String\s = "This is the message" + *String\s
Debug *String\s ; Bad String -> Memory leak
EndProcedure
S$ = "Test "
GetErrorMessage(@S$)
Debug S$Code: Select all
; API Methode
Procedure.i GetErrorMessage(*AnErrorMessage, MaxLen)
PokeS(*AnErrorMessage, Left("This is the message", MaxLen))
EndProcedure
text.s = Space(255)
GetErrorMessage(@text, Len(text))
Debug text

Code: Select all
#smax = 255
Define text.s = Space(#smax) ; "allocate"
Procedure s(*s,s.s)
; Shared text : text+Space(Len(s)) : *s=@text ; "redim" example
Protected *ss=*s
CopyMemoryString("Hello", @*ss) ; or e.g. (Left(s,#smax),@*ss), (Peeks(@protected_str$,#smax),@*ss)…
CopyMemoryString(" World!")
Debug PeekS(*s)
PokeS(*s,s,#smax,#PB_String_NoZero) ; no need for *ss
; PokeS(*s,PeekS(@s,#smax),-1,#PB_String_NoZero)
EndProcedure
s(@text,"Pizza")
Debug text
text = #Null$ ; to really free a stringCode: Select all
Procedure test(MyString.i)
Protected *s.string = @MySTRING
*s\s="This is the message"
Debug *s\s
Debug PeekS(MySTRING)
EndProcedure
test$=""
test(@test$)
Debug test$ + " outside the procedure"
Code: Select all
Procedure foo(*inout.string)
*inout\s + " World!"
EndProcedure
Define text.string ; <- Define String Pointer Structure
text\s = "Hello"
Debug SizeOf(text) ; Is a pointer to the structure
foo(text) ; <- Adress to the Structure with String Pointer
Debug text\s
Code: Select all
Procedure test(*s.string)
*s\s="This is the message"
EndProcedure
test(test.string)
Debug test\s + " outside the procedure"