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

Method evaluateFile

pluginbase/src/scopyjs.cpp:240–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240QJSValue ScopyJS::evaluateFile(const QString &path)
241{
242 QTextStream out(stdout);
243 QFile file(path);
244 if(!file.open(QFile::ReadOnly)) {
245 out << "Unable to open the script file: " << path << Qt::endl;
246 return "";
247 }
248 const QString scriptContent = getScriptContent(&file);
249 QJSValue val = ScopyJS::GetInstance()->engine()->evaluate(scriptContent, path);
250 if(val.isError()) {
251 out << "Exception:" << val.toString() << Qt::endl;
252 } else if(!val.isUndefined()) {
253 out << val.toString() << Qt::endl;
254 }
255
256 out.flush();
257
258 return val;
259}
260
261const QString ScopyJS::getScriptContent(QFile *file)
262{

Callers

nothing calls this directly

Calls 3

engineMethod · 0.80
openMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected