I'm trying to write a function that calls an external script but am not having any luck with the syntax
scripts_folder = "C:\\Program Files\\Autodesk\\3ds Max 2008\\Scripts"
var script1 = "hello_world.ms"
-- use function to call scripts
callScript(script1)
-- function callScript
function callScript script =
(
getFiles scripts_folder + "\\" + script
)
It's good to distinct two possible solutions here:
fileIn will do the same as "run script" or evaluate all in the editor. It can make a function available if it's globally declared (not preferable, use as less globals as possible), if it was locally declared within that script you cannot get to it.
Include actually takes the code from that file and injects it at that point. So if you have a large script and you want to organize things a bit better you can write certain functions in a separate file and include that function when the script get executed, so that function would always accessible because it is included in that scope.
Figured it out!
--- "hello_world.ms"
enter function hello =
(
print "hello the world"
)
---- another _script.ms
fileIn "hello_world.ms"
-- use function to call scripts
hello ()
It seems that fileIn works better than include
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With