We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I must be doing something fundamentaly wrong here...
Interpreter *pIr = this; // help addFunction("help", [pIr](const vector<string> &args) -> string { std::string result = "Available Functions:\n"; for (auto & a : pIr->allEntities()){ if (a.type == Interpreter::EntityType::FUNCTION) { result + a.name; result + "\n"; } } return result; });
returns ""
""
I want to list the functions defined in Interpreter... I have several, but help(); always returns empty.
help();
The text was updated successfully, but these errors were encountered:
Only functions that are used in the script are returned. Example:
int main(int argc, char* argv[]) { Interpreter ir; ir.addFunction("summ", [](const vector<string>& args) ->string { int res = 0; for (auto& v : args) { if (isNumber(v)) res += stoi(v); } return to_string(res); }); ir.addFunction("switch", [](const vector<string>& args) ->string { if (!args.empty()) { string key = args[0]; for (size_t i = 1; i < args.size(); ++i) { if (key == args[i]) { return "1"; } } } return "0"; }); ir.addFunction("print", [](const vector<string>& args) ->string { for (auto& v : args) { printf("%s\n", v.c_str()); } return ""; }); ir.addFunction("help", [&ir](const vector<string>& args) -> string { std::string result = "Available Functions: "; for (auto& a : ir.allEntities()) { if (a.type == Interpreter::EntityType::FUNCTION) { result += a.name + ","; } } result.pop_back(); return result; }); string scenar = "$a; $b; summ($b, $a); switch($a, 5); help();"; string res = ir.cmd(scenar); // summ,switch,help return 0; }
Debug like this:
Sorry, something went wrong.
No branches or pull requests
I must be doing something fundamentaly wrong here...
returns
""
I want to list the functions defined in Interpreter... I have several, but
help();
always returns empty.The text was updated successfully, but these errors were encountered: