[Closed] "This" inside Struct
I just realized today “This” variable works inside struct and refers to the struct itself, like class definition in C#.
as i remember ‘this’ was added to structure with max 2009. and it’s documented!
it is super useful addition. you can find its using in many examples and snippets on this forum.
i’m looking now in max 2014 mxs help (.chm version) and can’t find anything about ‘this’ in structure. it looks like missed! i’m absolutely sure it was documented. the same as public and private variables, and on create and clone handles.
as i said the ‘this’ very useful (in many cases necessary) thing.
one of an examples of ‘this’ using is in my posts about – “one tool – one file – one structure”
where i’ve passed structure pointer to a rollout declared inside this structure
struct theStruct
(
dialog = rollout dialog ""
(
local owner = if owner != undefined do owner
on open do format ">>> %
" owner
),
on create do
(
dialog.owner = this
createdialog dialog
)
)
another one is the passing structure pointer to its own .net controls. http://forums.cgsociety.org/showpost.php?p=7190533&postcount=8
also using ‘this’ helps to realize forward declaration in structs
struct theStruct
(
fn printSomething = print this.something,
something = "something",
on create do printSomething()
)
(i don’t max to try these examples, but they show the ideas)