Posted 08 April 2013 - 02:05 PM
Hi,
I have coded something which can add environment variables to your os. So an environment variable are predefined variables that return paths to directories on your OS. Windows has environment variables and they look like this: %<VAR>% and when called return what is set to. For example the %APPDATA% environment variable returns the following:
C:\Users\<USERNAME>\AppData\Roaming. So if I opened up a new command prompt and typed: echo %APPDATA% it would print C:\Users\<USERNAME>\AppData\Roaming.
I have coded a startup to modify the ComputerCraft BIOS and define the environment variables.
( THIS NEEDS TO BE RUN AT EACH STARTUP TO WORK )
Heres the code:
With this I can go on to any program provide this has been run first and type variables which have been set here. These variables are global so they can be access from anywhere if this file has run.
This is handy for shorting and making OS' more user controllable because using this you can a user can set the install dir of the OS provided again that the OS has used these env vars.
Heres an example of how to use it. Also I have run this program at the startup
I have coded something which can add environment variables to your os. So an environment variable are predefined variables that return paths to directories on your OS. Windows has environment variables and they look like this: %<VAR>% and when called return what is set to. For example the %APPDATA% environment variable returns the following:
C:\Users\<USERNAME>\AppData\Roaming. So if I opened up a new command prompt and typed: echo %APPDATA% it would print C:\Users\<USERNAME>\AppData\Roaming.
I have coded a startup to modify the ComputerCraft BIOS and define the environment variables.
( THIS NEEDS TO BE RUN AT EACH STARTUP TO WORK )
Heres the code:
-- RBOOT
-- Imque 2013
local version = "RBOOT 0.1" -- OS' VERSION
local author = "Imque 2013" -- YOUR NAME
env = {
ROOT_ENV_LOC = "/root/", -- ROOT PATH LOCATION
LIB_ENV_LOC = "/root/lib/", -- LIB PATH LOCATION
ETC_ENV_LOC = "/root/etc/", -- ETC PATH LOCATION
USR_ENV_LOC = "/root/usr/" -- USR PATH LOCATION
}
_ROOT = env.ROOT_ENV_LOC -- ROOT ENV VAR
_LIB = env.LIB_ENV_LOC -- LIB ENV VAR
_ETC = env.ETC_ENV_LOC -- ETC ENV VAR
_USR = env.USR_ENV_LOC -- USR ENV VAR
-- UPDATE OS.VERSION
os.version = function()
return version
end
-- RUN SCRIPT
shell.run(_ROOT .. "shell") -- Shell script
With this I can go on to any program provide this has been run first and type variables which have been set here. These variables are global so they can be access from anywhere if this file has run.
This is handy for shorting and making OS' more user controllable because using this you can a user can set the install dir of the OS provided again that the OS has used these env vars.
Heres an example of how to use it. Also I have run this program at the startup
os.load(_LIB .. "my api located in the /root/lib/ dir.")
fs.makeDir(_ROOT .. "another dir")
fs.delete(_ETC .. "main")
print(os.version()) -- prints what version was set to in the startup file
-- you get the idea.