[Closed] include vs. filein?
This may help?
http://tech-artists.org/wiki/index.php/Macro_installation_(maxScript)
There are also a few sections in Help that will aid you.
I should also mention I don’t find Paul’s comment that cold, you’ve made about half a dozen threads in the past couple days. Whether or not it is true, it gives the impression you aren’t trying as hard as you should be, since your questions aren’t exactly difficult or new (there is a good Search functionality here that you should try to use more often).
That page seems liek its goign to help me a lot actually…
And as for the threads I’ve made recently…I see what you mean…and what makes it come across as so unprepared is the fact that I’ve kinda spent the last few months working this script, and the rash of threads is basically the final stages and polishing off to close this project down…Its kinda like I saved all my questions till the end.
Terribly sorry about all that, and thanks for the link!
Ok…Its coming along…your link helped quite a bit actually…I’m understanding a bit more about how the macroscripts thing is working…though I’m not sure if I like it…I’m thinking perhaps macroscript isn’t what I want to use???
I’m currently having a function scope problem and I’ve tried various different combinations of global declaration and everything, to no avail.
I’ve got it set up like so:
my scripts\startup folder has an ms file that merely calls the base macro in the scripts\xplane folder which is XPlaneObj8ToolsBase.mcr
scriptsDir = getDir #scripts
f = scriptsDir + "\\XPlane\\XPlaneObj8ToolsBase.mcr"
fileIn f
The macro file has this in it.
MacroScript XPlaneObj8Tools category:"X-PlaneObjTools"
(
include "XPlane\\Helpers.ms"
include "XPlane\\Modifiers.ms"
include "XPlane\\Functions.ms"
include "XPlane\\Export.ms"
include "XPlane\\Import.ms"
XPlaneObjRolloutFloater = newRolloutFloater "X-Plane OBJ Tools" 250 300
addrollout XPlaneObj8Export XPlaneObjRolloutFloater
addrollout XPlaneObj8Import XPlaneObjRolloutFloater
)
I have a function that is defined in functions.ms that is basically a filter for a pick button. When this was all in one file, it appeared to work…now that I’ve split it into multiple files the function doesn’t seem to want to be found…even though all the helpers, modifiers, and rollouts do.
The function is declared in the root of the functions.ms file, and its being called as a ui element of one of the simplemods in modifiers.ms
I tried putting the function call inside the simplemod () block and it recognized it…but the filter is filtering it to the classof the scripted helper in helpers.ms…which it then doesn’t recognize…
So its either not recognizing the function if its defined outside of the simplemod, or its not recognizing the helper its filtering to if its defined inside the simplemod…What gives?
It is probably a scope problem, as you assume (I assume it is giving you the ‘Type error: Call needs function or class, got: undefined’?)
You need to make sure your functions are declared before they are evaluated in any script. I can try to give you an example from my experience. I was using the function myStruct.myFunction in a script before I was declaring what myStruct was- whenever I ran the script, I would get the Type error undefined error. Honestly, I am not exactly sure why, even though it should be simple (I know the simple answer but it still doesn’t seem right- if I use it undeclared, adn then later declare it as a Global, shouldn’t that first call look to the global?).
Lesson is, make sure anything you use is declared BEFORE you use it. The best thing you can do is break out all your common functions into some Structs that you load before the actual macro, that way you will not get any scope problems/conflicts.
which puts me into a bit of a quandary…chicken or egg first…
I have a simplemod that needs a function that filters a pickbutton so it only lets the user pick the helper object. I can globally declare the function, but it still needs to know the scripted helper object.
The fact that its all happening inside the () block of a macroscript (assuming include declares everything in the order in which its included) confuses me greatly…does the order in which it appears in the macroscript file specify the order in which its declared?
The actual error I get is code block not created, unable to access code block local or parameter: pivot_filter
Uh oh… are you using globals/external variables in your functions? Or is everything you are using in your function declared as a local in your function or passed in as a parameter? If you are not using an external values in your functions, then no idea, without seeing the actual code.
I think I figured it out…I had EVERYTHING happening INSIDE of the macroscript…I’ve moved the scripted helpers, simplemods, and functions outside of the macroscript, and left only the export and import rollouts inside the macroscript…so this way the helpers, mods, and functions are already declared when the macro fires. I think…so far so good…we’ll see.
Now…if someone can figure out http://forums.cgsociety.org/showthread.php?f=98&t=649625 I’ll have pretty much all of my questions answered for the moment.
Thanks much!!!