Hello!
I've been working on my OS for quite some time now, and I have run into the need to implement in my API a function to read variables out of files. These can be, and usually are, standard programs which happen to have a variable that I need in my main loop to execute them properly. How do I do this? The desired output would be a table similar to that returned by os.loadAPI, but with variables instead of functions, the index being the variable name and the value, its value. Thanks a lot!
Reading variables from files
Started by MarioBG, Jul 08 2015 09:23 AM
1 reply to this topic
#1
Posted 08 July 2015 - 09:23 AM
#2
Posted 08 July 2015 - 02:22 PM
Lets say your file is named config, and it looks like this:
You could simply do this:
...because os.loadAPI gets all globally declared variables. Obviously, if you localize your variables (as with functions) they will not be available.
textColor = colors.blue backgroundColor = colors.black
You could simply do this:
os.loadAPI( "config" ) term.setTextColor( config.textColor ) term.setBackgroundColor( config.backgroundColor )
...because os.loadAPI gets all globally declared variables. Obviously, if you localize your variables (as with functions) they will not be available.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











