Yeah yeah, there's already a bunch of these floating around. But, this uses the Windows environment variables. Now, from my own experience, this won't set the "global" environment variables, rather the process/application specific variables. So this could be used for 2 things, a) Commercial applications which may need to be registered and b) Games/Scripting.
Here's a small example:
REM Project: CVar System
REM Created: 11/25/2007 2:49:52 AM
REM
REM ***** Main Source File *****
REM
````Test
StartCVarSystem(10)
SetCVar("player_health", "100")
SetCVar("player_mana", "50")
print GetCVar("player_health")
print GetCVar("player_mana")
wait key
EndCVarSystem()
end
````/Test
`Required by the system
global g_CVarSystem_Dll as integer
`Call this at startup
function StartCVarSystem(DllId)
g_CVarSystem_Dll = DllId
load dll "Kernel32.Dll", DllId
endfunction
`Call this at end
function EndCVarSystem()
delete dll g_CVarSystem_Dll
endfunction
`Set a CVar
function SetCVar(name$, value$)
call dll g_CVarSystem_Dll, "SetEnvironmentVariableA", name$, value$
endfunction
`Get a CVar
function GetCVar(name$)
for i = 0 to 255
ret$ = ret$ + chr$(0)
next i
call dll g_CVarSystem_Dll, "GetEnvironmentVariableA", name$, ret$, 255
endfunction ret$
And here's the functions:
`Required by the system
global g_CVarSystem_Dll as integer
`Call this at startup
function StartCVarSystem(DllId)
g_CVarSystem_Dll = DllId
load dll "Kernel32.Dll", DllId
endfunction
`Call this at end
function EndCVarSystem()
delete dll g_CVarSystem_Dll
endfunction
`Set a CVar
function SetCVar(name$, value$)
call dll g_CVarSystem_Dll, "SetEnvironmentVariableA", name$, value$
endfunction
`Get a CVar
function GetCVar(name$)
for i = 0 to 255
ret$ = ret$ + chr$(0)
next i
call dll g_CVarSystem_Dll, "GetEnvironmentVariableA", name$, ret$, 255
endfunction ret$
Cheers,
-naota
Madness never stops..... It takes a breather every once in a while, but then it grabs it's inhaler and chases you down the street with a cane.
Aex.Uni forums