The poor OP is probably totally confused at this point!
Let me try to clarify:
First Issue: does variable assignment Copy or Reference?
E.g. what happens when I have two variables, A and B and I say
B = A
Is B now a Copy of A, or is B actually pointing to A ?
In other words, will changes to B affect A, or not?
That’s the concept of “value type” (Scalar type) vs. “Reference type”
In Xojo, many things are Scalar Type:
Integer (and all variations), String, Double,…
For example:
var A as integer = 42
var B as integer = A
B = 99
// at this point, A = 42, and B = 99 - they are not the same thing
With other types (Array, Object…) B is actually a reference to A:
var A() as integer = Array(1,2,3)
var B() as integer = A
B(0) = 99
// at this point, A and B are the same object, an Array containing: (99,2,3)
Second Issue: in a Function (or Method), what happens if you change the Parameter? Do changes get back out of the Function?
This is the concept of “passing by Value” vs. “passing by Reference”
By default in Xojo, all Function or Method parameters are passed ByValue, meaning a copy is made for use inside the function (or Method) and any changes to that value are lost when the function (or Method) ends.
Function AddOne(x as integer)
x = x +1
// x has been increased by one, but that change is lost when the function ends.
End Function
var x as Integer = 9
AddOne(x)
// x is still 9
vs.
Function AddOne(ByRef x as integer)
x = x +1
// x has been increased by one, and since it's a 'ByRef' parameter, that change gets out of the function.
End Function
var x as Integer = 9
AddOne(x)
// x is 10