MCPcopy Create free account
hub / github.com/NatLabRockies/SAM / fcall_value

Function fcall_value

src/invoke.cpp:1228–1262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1226}
1227
1228void fcall_value( lk::invoke_t &cxt )
1229{
1230 LK_DOC("value", "Gets or sets the value of a variable by name", "(string:name [,variant:value, bool:trigger value change (default true)]):[variant]");
1231
1232 CaseCallbackContext &cc = *(CaseCallbackContext*)cxt.user_data();
1233 wxString name = cxt.arg(0).as_string();
1234 auto& c = cc.GetCase();
1235 bool found = false;
1236 // Issue 1965 - assumption is that higher ndxHybrid vartables contain independent vairables in startup.lk
1237// for (size_t ndxHybrid = 0; !found && ndxHybrid < c.GetConfiguration()->Technology.size(); ndxHybrid++) {
1238 for (int ndxHybrid = c.GetConfiguration()->Technology.size() - 1; !found && ndxHybrid > -1; ndxHybrid--) {
1239 if (VarValue* vv = cc.GetValues(ndxHybrid).Get(name))
1240 {
1241 found = true;
1242 if (cxt.arg_count() > 1)
1243 {
1244 if (vv->Read(cxt.arg(1), false)) {
1245 bool trigger = true;
1246 if (cxt.arg_count() == 3) {
1247 trigger = cxt.arg(2).as_boolean();
1248 }
1249 if (trigger) {
1250 cc.GetCase().VariableChanged(name, ndxHybrid);
1251 }
1252 }
1253 else
1254 cxt.error("data type mismatch attempting to set '" + name + "' (" + vv_strtypes[vv->Type()] + ") to " + cxt.arg(1).as_string() + " (" + wxString(cxt.arg(1).typestr()) + ")");
1255 }
1256 else
1257 vv->Write(cxt.result());
1258 }
1259 }
1260 if (!found)
1261 cxt.error("variable '" + name + "' does not exist in this context" );
1262}
1263
1264void fcall_is_assigned( lk::invoke_t &cxt )
1265{

Callers

nothing calls this directly

Calls 9

sizeMethod · 0.80
GetValuesMethod · 0.80
VariableChangedMethod · 0.80
TypeMethod · 0.80
GetCaseMethod · 0.45
GetConfigurationMethod · 0.45
GetMethod · 0.45
ReadMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected