View Full Version : Include issues
03-09-2009, 01:34 PM
I'm using a .ms file as a library with my general functions. I've been using include to use the functions within other scripts. This works fine as long as the directory containing the library doesn't change. I'm distributing my scripts over several pc's with different directories now, and want to include the same file using getDir #userStartupScripts.
However, Maxscript wants the exact directory name to include. So the following will give an error:
include ((getDir #userStartupScripts) + "\\MV_Lib\\MV_lib_1.08.ms")
-- Error occurred in anonymous codeblock; filename: D:\Scripts\- Projects\MV_MatSlotInfo.ms; position: 3385
-- Compile error: include expected filename string
-- In line: include (
Because include is a compile-time construct, the current MAXScript scope is maintained within the included file. This is opposed to the fileIn() method described in Running Scripts, whose script file content is compiled in a global scope context.
Is there any way I can include a variable folder? Or should I go with fileIn instead?
03-09-2009, 01:44 PM
depends on whether or not your code is context dependent.. if it's a 'library', though, essentially inserting it into your code with 'include' is probably not what you'd want and fileIn may be more appropriate. Though if it's included at the top of the script, outside of inner contexts, the effect is pretty much the same as fileIn anyway.
One other thing you can try is using the symbolic pathname for the startup folder; "$startupScripts". E.g. include "$startupScripts\\MB_Lib\\MB_lib_1.08.ms"
03-09-2009, 02:22 PM
Thanks, $userStartupScripts works.
The library is context dependent at the moment yes, couldn't get fileIn to work. I'm planning to optimize this whenever I have some more time, at the moment I just need it to run.
03-09-2009, 02:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.