Notifications
Clear all

[Closed] include with variable

Hi

I`m attempting to support multiple Max installs with my scripts so I want to be able use a variable for the include string

Something like

sPath = ( getDir #Scripts + "\\ToolsFolder\\" + scriptName.ms
include sPath

This results in an error for me im told because the include is a PreProcess so none of the max code works,

Any thoughts on how to do this would be great, or any suggestions on how others are doing this would be awesome
Thanks
Dave

6 Replies
1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

the right parenthesis is definitely missed in this code.
but it’s a coding error. it could be easily fixed. what’s your real problem?

Make sPath global, defined it once, skip the include part for this variable?

thanks for the suggestion but maybe im misundertanding,

if i skip the include part then how do you include an .ms file into an mcr?

I also dont understand the reason to make the variable global, this would allow me either to access the path from any part of the maxscripts or to overwrite it per script import but the import still fails,

A little more info, the way i have set up the scripts is with ms files containing the functionality of tools and the mcr just includes them to allow the users to create buttons and me to add it to the main toolbar menu.

ah yeah that was just a typo here as i typed it ina nd dint copy it from any script

sPath = ( getDir #Scripts + "\\ToolsFolder\\" + "scriptName.ms" )
include sPath

running that while doing fileIn upon max loading results in the error

-- Compile error: include expected filename string 
--  In line: include s <<

im including ms files into mcr`s to create tool functionality, what i want is to be able to put the mcr in any install of Max and it looks for the script file that is in that version of max so the code above in max 2013 scripts folder would include the file
C:\Program Files (x86)\Autodesk\3ds Max 2013\scripts\ToolsFolder\scriptName.ms
and the same mcr file in max 2014 would include the file
C:\Program Files\Autodesk\3ds Max 2014\scripts\ToolsFolder\scriptName.ms
because of the getDir #Scripts

but it complains expected filename string blah…

Try with ‘filein’ instead :

sPath = ( getDir #Scripts + "\\ToolsFolder\\" + "scriptName.ms")  
filein sPath

i shall try fileIn soon but that means that the file is in global scope and not in the file itself so the scoping is lost