Page 1 of 1

Passing a string to a procedure by reference

Posted: Mon Sep 22, 2025 3:28 am
by Axeman

Code: Select all


; This procedure receives a string passed by reference and outputs its value via the 'Debug' command.
; Note that the string is stored in the 's' field of the default 'STRING' structure.
Procedure Test1( *str_pointer.STRING )
Debug *str_pointer\s
EndProcedure


; This procedure receives a string passed by reference and changes its value.
; Note that the string is stored in the 's' field of the default 'STRING' structure.
Procedure Test2( *str_pointer.STRING )
*str_pointer\s = "def"
EndProcedure


; This procedure passes strings by reference to the previous procedures to test the result.
; Note that the string is stored in the 's' field of the default 'STRING' structure. All reading and writing should be done with that field.
Procedure Test3()
Protected mystring.STRING
mystring\s = "abc"
Test1( @mystring )
Test2( @mystring )
Debug mystring\s
EndProcedure


Test3()