interface wack
//... some declarations
endinterface
struct wek extends wack
integer x
// some more declarations
endstruct
function test takes wack W returns nothing
//You are certain that W is of type wek, a way to cast the value is:
local wek jo = W
set jo.x= 5 //done
// but sometimes creating a variable is too much work for the virtual machine and you
// are only accessing it once
set wek(W).x=5 //also works.
endfunction
type anarrayofdata extends integer array [6]
function getdata5 takes unit u returns integer
//a reference to an object of type anarrayofdata is saved as the unit's custom value
return anarrayofdata(GetUnitUserData(u))[5]
endfunction
function setdata5 takes unit u, anarrayofdata x returns nothing
// Here we are doing the opposite, notice that integer may be used as a type cast
// operator for struct and dynamic array types.
call SetUnitUserData(u, integer(x))
endfunction