#MAX_VALUE=3
Structure TESTSTRUCT
name.s
number.l
array_string.s[#MAX_VALUE]
array_long.l[#MAX_VALUE]
array_word.w[#MAX_VALUE]
array_byte.b[#MAX_VALUE]
EndStructure
mystruct.TESTSTRUCT
mystruct\name="Test String"
mystruct\number=3665412
For i=0 To #MAX_VALUE-1 : mystruct\array_string[i]="String Array "+Str(i) : Next
For i=0 To #MAX_VALUE-1 : mystruct\array_long[i]=Random(100) : Next
For i=0 To #MAX_VALUE-1 : mystruct\array_word[i]=Random(100) : Next
For i=0 To #MAX_VALUE-1 : mystruct\array_byte[i]=Random(100) : Next
Procedure Display_TESTSTRUCT(*outstruct.TESTSTRUCT)
Debug(*outstruct\name)
Debug(*outstruct\number)
For i=0 To #MAX_VALUE-1 : Debug(*outstruct\array_string[i]) : Next
For i=0 To #MAX_VALUE-1 : Debug(".L Array "+Str(*outstruct\array_long[i])) : Next
For i=0 To #MAX_VALUE-1 : Debug(".W Array "+Str(*outstruct\array_word[i])) : Next
For i=0 To #MAX_VALUE-1 : Debug(".B Array "+Str(*outstruct\array_byte[i])) : Next
EndProcedure
Display_TESTSTRUCT(@mystruct)
Restored from previous forum. Originally posted by Franco.
Keep in mind, you don't copy the values from mystruct to outstruct.
You only pass the pointer to the procedure, mystruct and outstruct share the same pointer.
If you change the values in the mystruct structure also the values getting from outstruct are changed!
If you need access to a structure inside a procedure you have to use the shared command:
Restored from previous forum. Originally posted by freak.
@Franco,
The shared Command actually does exactly the same, if you now change some Value in the Procedure, it is also changed in the main Prog, because now it is not only the same pointer, but also the same variable