MCPcopy Create free account
hub / github.com/analogdevicesinc/scopy / evaluateCode

Method evaluateCode

core/src/scriptingtool.cpp:181–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181void ScriptingTool::evaluateCode(QString code)
182{
183 QString timestamp = QDateTime::currentDateTime().toString("hh:mm:ss");
184 QString output;
185
186 QJSValue val = ScopyJS::GetInstance()->engine()->evaluate(code, "");
187 int ret = EXIT_SUCCESS;
188 if(val.isError()) {
189 qWarning(CAT_SCRIPTINGTOOL) << "Exception:" << val.toString();
190 ret = EXIT_FAILURE;
191 output += timestamp + ": Exception:" + val.toString();
192 } else if(!val.isUndefined()) {
193 qWarning(CAT_SCRIPTINGTOOL) << val.toString();
194 output += timestamp + ": " + val.toString();
195 }
196
197 if(m_runBtn->isChecked())
198 output += "\n" + timestamp + ": Script finished with status " + QString::number(ret);
199
200 m_console->appendPlainText(output);
201
202 if(m_runBtn->isEnabled()) {
203 m_runBtn->setChecked(false);
204 }
205}
206
207#include "moc_scriptingtool.cpp"

Callers

nothing calls this directly

Calls 4

engineMethod · 0.80
setCheckedMethod · 0.80
toStringMethod · 0.45
isEnabledMethod · 0.45

Tested by

no test coverage detected