I am also a bit confused by the discussion about UDT´s
I think if passing by value works correctly following code should be OK. f1() can not access the first member of the UDT.
rem
rem AGK Application
rem
rem A Wizard Did It!
createtext(1,"")
createtext(2,"")
createtext(3,"")
settextposition (1,10,10)
settextposition (2,10,20)
settextposition (3,10,30)
type person
famname as string
name as string
endtype
main()
end
function main()
p1 as person
p1.name="peter"
p1.famname = "jonckheere"
settextstring(1,"1:" + p1.name +":" + p1.famname)
settextposition (1,10,10)
f1(p1)
do
Sync()
loop
endfunction
function f1( p as person )
settextstring(2, "2:" + p.name + ":" + p.famname)
f2(p)
endfunction
function f2(p as person)
settextstring(3, "3:" +p.name + " " + p.famname)
endfunction
// only the first member of the UDT can be accessed ?
I wonder why this works as a workaround
rem
rem AGK Application
rem
rem A Wizard Did It!
createtext(1,"")
createtext(2,"")
createtext(3,"")
settextposition (1,10,10)
settextposition (2,10,20)
settextposition (3,10,30)
type person
famname as string
name as string
endtype
main()
end
function main()
global p1 as person // added global
p1.name="peter"
p1.famname = "jonckheere"
settextstring(1,"1:" + p1.name +":" + p1.famname)
settextposition (1,10,10)
f1(p1)
do
Sync()
loop
endfunction
function f1( p as person )
global pp as person // declared extra global variable
pp = p // assigned function parameter to it
settextstring(2, "2:" + p.name + ":" + p.famname)
f2(pp)
endfunction
function f2(p as person)
settextstring(3, "3:" +p.name + ":" + p.famname)
endfunction