[Closed] Accessing dependant structs
Hi
So I have two structs, an xml struct and a project struct with various functions in each, what I want to do is inside the project struct create a new instance of the xml struct to work with the projects xml but because the xml .ms file hasn’t been read in yet it crashes, understandable p is before x when I loop offer the files doing a fileIn.
So because max doesn’t have inheritance in structs (or please correct me if I’m wrong) I have two options, use include() with an absolute path to the xml struct in the project struct, which I don’t want to do because this means if I ever have to change the location of the scripts I will have to change a whole bunch of paths, or carefully and manually control which files are read in first before others depending on which have dependencies on others, this sounds like it could get real complicated fast.
Which would you recommend or is there a better way of doing this?
Thoughts?
Thanks
All the “batch” issues for this and similar situations should be solved by simply explicitly declaring the structures in this case or functions in other cases, either as local or global, as you need them to be.
For example, the following will throw an exception, as structure_b is not visible to structure_a:
(
struct struct_a
(
val = 1,
b = struct_b(),
fn GetValA = return val,
fn GetValB = return b.val
)
struct struct_b
(
val = 5
)
inst = struct_a()
inst.GetValB()
)
But if we declare both of them ahead (no matter the order), both are visible to each other, like:
(
local struct_a, struct_b
struct struct_a
(
val = 1,
b = struct_b(),
fn GetValA = return val,
fn GetValB = return b.val
)
struct struct_b
(
val = 5
)
inst = struct_a()
inst.GetValB()
)
Hi polytools
Thanks for the suggestion it does make sense what you said but really didn’t seem to work, don’t know why as I have declared functions before and this is the same, I have no gone forward reading in the xml and a couple of other structs, I think this is going to be a better for the way I have the scripts setup at the moment
Thanks
Hi
I am an idiot, when i tried it before i declared the structs in a file that was not being read in before the structs themselves dam im stooopid some days. Works perfectly thanks for the help