[Closed] Script include problem
Hello all !
I am trying to start organizing my scripts and encountered a problem : it seems two script files can’t depend on each other.
suppose I have in script.ms :
--script.ms
function myFunction k = 10 * k
and in script1.ms :
--script1.ms
fileIn "script.ms"
function myFunction1 k = (myFunction k) * 10
It works fine.
I just need to execute script1.ms and it will execute script.ms.
But if I have another function in script.ms that uses myFunction1 :
--script.ms
function myFunction k = 10 * k
function myOtherFunction k = (myFunction1 k) / 10
Then it won’t work, unless I execute script.ms two times, one before script1 and one after.
I know it is better to have dependencies only one way, but sometimes you can’t really do things the “better” way…
So am I doing it incorrectly ? How do you manage dependencies between your scripts ?
Thanks in advance
Yannick
You could use forward declaring of either or both functions. So in file A you’d declare a function that is located in file B, without an implementation. Then in file B you declare it with an implementation.
It’s not a great way of doing it, but it’s a way of working around dependency issues.