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

Function fcall_set

src/script.cpp:212–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210
211
212void fcall_set( lk::invoke_t &cxt )
213{
214 LK_DOC( "set", "Set an input variable's value. Issues a script error if the variable doesn't exist or there is data type error.", "(string:name, variant:value):none" );
215 cxt.result().assign( 0.0 );
216 wxString name = cxt.arg(0).as_string();
217 if ( Case *c = CurrentCase() )
218 {
219 wxString var_name;
220 size_t ndx_hybrid;
221 UpdateVarNameNdxHybrid(c, name, &var_name, &ndx_hybrid);
222 if ( VarValue *vv = c->Values(ndx_hybrid).Get( var_name ) )
223 {
224 if ( vv->Read( cxt.arg(1), false ) )
225 c->VariableChanged( var_name, ndx_hybrid );
226 else
227 cxt.error( "data type mismatch attempting to set '" + name + "' (" + vv_strtypes[vv->Type()] + ") to " + cxt.arg(1).as_string() + " ("+ wxString(cxt.arg(1).typestr()) + ")" );
228 }
229 else
230 cxt.error("variable '" + name + "' does not exist in the current case" );
231 }
232 else cxt.error("no active case");
233}
234
235void fcall_get( lk::invoke_t &cxt )
236{

Callers

nothing calls this directly

Calls 7

CurrentCaseFunction · 0.85
UpdateVarNameNdxHybridFunction · 0.85
assignMethod · 0.80
VariableChangedMethod · 0.80
TypeMethod · 0.80
GetMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected