23 posts
Posted 28 August 2016 - 02:02 AM
This has stumped me for a long time now. I have two files:
file1:"unet"
file2:"unetclientdata/libraries/rnetconfigx12"
I need the unet program to load the entire file, rnetconfigx12, and run it as if the code for file2 was part of file1.
Sorry if this is too much, but I also need them to be compatible with each other. As in file 2 can call functions from file 1 and vise versa.
Any help is appreciated!
3057 posts
Location
United States of America
Posted 28 August 2016 - 02:37 AM
This PIL Chapter may be of use to you.
23 posts
Posted 28 August 2016 - 02:56 AM
I took a look at the PIL, and had some trouble with it. But what I have gathered is that I might need to use loadfile to get the code over to file1? correct me if i'm wrong
3057 posts
Location
United States of America
Posted 28 August 2016 - 03:05 AM
loadfile would be one of the ways, yes.
23 posts
Posted 28 August 2016 - 03:09 AM
If I do loadfile, will that allow for one file to call functions of the other?
23 posts
Posted 28 August 2016 - 04:49 PM
I have tried loadfile, and the other script runs like it should. Sort of. The two scripts however don't communicate with each other, and I cannot call functions that are stored in the other file correctly. Any ideas?
7083 posts
Location
Tasmania (AU)
Posted 29 August 2016 - 05:45 AM
As in file 2 can call functions from file 1 and vise versa.
This sounds ominous - there's seldom good reason to go both ways like that. Are you planning on making recursive calls? If so (and if you don't understand what they are, assume "yes"), are you aware of the potential pitfalls?
If you really "must" store your code across multiple files, then your main problem boils down to
scope. You can share the global
environment between your separately loaded files, but I'm not aware of any way to do this with values declared local to the individual files.
I'm strongly suspecting that you'd be better off looking into CC's
API system.
23 posts
Posted 29 August 2016 - 04:24 PM
I have taken into account the api system and have even employed it once in the code. However I still was not able to call functions properly and it came up with an error that said the function I was asking for was a nil. I've looked over both scripts and they are both pretty close to devoid of bugs, as I debug as I go. I really don't know what I'm doing wrong. It might be a bug in my code, which I could sort out, but I need to make sure that what I do, can atleast call functions from the other script.
P.S Thanks for the help so far. :)/>
7083 posts
Location
Tasmania (AU)
Posted 30 August 2016 - 06:47 AM
Odds are someone could point out the problems to you if you were to display your code.
http://www.pastebin.com
2427 posts
Location
UK
Posted 30 August 2016 - 09:06 AM