Regular API function

simExecuteScriptString / sim.executeScriptString

Description Executes some code in a specific script (from a plugin, the main client application, or from another script). The target script must be initialized for this call to succeed, e.g. when calling simulation scripts, then simulation must be running. See also sim.callScriptFunction.

Data exchange between a plugin and a script happens via a stack. Reading and writing arguments from/to the stack gives you a maximum of flexibility, and you wil be able to exchange also complex data structures. But it can also be tedious and error prone. Use instead the helper classes located in programming/include/simStack.
C/C++
synopsis
int simExecuteScriptString(int scriptHandle,const char* stringToExecute,int stackId)
C/C++
parameters
scriptHandle: the handle of the script
stringToExecute: a string representing the code to execute in the specified script
stackId: 0 (for no stack) or a stack handle. The stack holds possible out values. See also the available stack functions.
C/C++
return value
-1 in case of an error
Lua
synopsis
int result,executionResult=sim.executeScriptString(string stringToExecute,int scriptHandle)
Lua
parameters
Similar to the C-function counterpart
Lua
return values
result: -1 in case of an error
executionResult: return value of the executed code
Python
synopsis
int result,executionResult=sim.executeScriptString(string stringToExecute,int scriptHandle)