User forums > Using Code::Blocks
[RESOLVED]Squirrel set $(var_name)
BlueHazzard:
I have also updated the wiki article: http://wiki.codeblocks.org/index.php/Scripting_commands#Plugins_with_script_bindings and http://wiki.codeblocks.org/index.php/Environment_Variables_plugin if someone found an error please report, or help by fixing it :)
thank you!
Suryavarman:
Really thank you.
But i haven't the Envar Plugin, may be the reason is that : I have build codeblocks without this plugin :p
I try to find how to activate this plugin and I will tell you.
Suryavarman:
Thats so great, it's Works :)
8)
Here my code to load a config file:
--- Code: ---class Dependencies
{
constructor()
{
local deps_config_filename = ::ReplaceMacros(_T("$(PROJECT_DIR)"));
deps_config_filename += _T("./../../dependencies/dependencies.cfg");
local config_exist = IO.FileExists(deps_config_filename);
assert(config_exist);
if(config_exist)
{
local file_content = IO.ReadFileContents(deps_config_filename);
local groups = GetArrayFromString(file_content, _T("["), true);
local commands = wxArrayString();
for(local i = 0; i < groups.GetCount(); i++)
{
local group = GetArrayFromString(groups.Item(i), _T("]"), true);
local groupName = group.Item(0);
local values = GetArrayFromString(group.Item(1), _T("\n"), true);
for(local j = 0; j < values.GetCount(); j++)
{
local keyvalue = GetArrayFromString(values.Item(j), _T("="), true);
if(keyvalue.GetCount() != 2)
{
ShowError(_T("Pour le groupe: " + groupName + " et valeur: " + j + " il y a plus d'un charactère '='."));
}
local key = keyvalue.Item(0).MakeUpper();
local value = keyvalue.Item(1);
key = ::EscapeSpaces(key);
value = ::EscapeSpaces(value);
key_paths.rawset(key, value);
EnvvarApply(key, value);
}
}
}
}
key_paths = {};
}
function SetBuildOptions(base)
{
local deps = Dependencies();
}
--- End code ---
Suryavarman:
I take advantage of the opportunity to ask if codeblocks have plane to:
1 - make a bijection between wxString <-> Squirrel String.
2 - make possible to use wxString to define Data.key like that :
--- Code: ---local data = {};
local value = 2;
data.rawset{_T("KEY"), value);
print(data.rawget(_T("KEY"))); // error there are no key.
--- End code ---
Actually this code works:
--- Code: ---local data = {};
local key = _T("KEY");
local value = 2;
data.rawset(key, value);
print(data.rawget(key)); // print 2 because key pointer adress is using by Squirrel to find the key.
--- End code ---
data.
BlueHazzard:
--- Quote ---1 - make a bijection between wxString <-> Squirrel String.
--- End quote ---
we have an experimental build where this was possible. Maybe in the future we will work on this more.
The first step in the near future is to update squirrel to the latest release, because codeblocks uses the old version 2 and not 3.1.
In general you can normally use squirrel strings everywhere, and put them trough
--- Code: ---_T()
--- End code ---
in the last step before the codeblocks function...
--- Code: ---local iAmAsquirrelString = "hello";
iAmAsquirrelString += " world";
// Now you put it into a codeblocks function, use _T() to convert it
Log(_T(iAmAsquirrelString ));
--- End code ---
Basically the same is the other way around by using the
--- Code: ---tostring()
--- End code ---
function:
--- Code: ---Log(_T(_T("test").tostring()));
--- End code ---
I really would like to improve the squirrel support, but there are tons of other things on the todo list, and time is limited...
Navigation
[0] Message Index
[*] Previous page
Go to full version