MCPcopy Create free account
hub / github.com/El-EnderJ/NeoCalculator / createNewScript

Method createNewScript

src/apps/PythonApp.cpp:434–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434void PythonApp::createNewScript() {
435 if (_scriptCount >= MAX_SCRIPTS) return;
436
437 // Generate a unique name
438 char name[MAX_FILENAME];
439 for (int n = 1; n < 100; ++n) {
440 snprintf(name, sizeof(name), "script%d.py", n);
441 bool exists = false;
442 for (int i = 0; i < _scriptCount; ++i) {
443 if (strcmp(_scriptNames[i], name) == 0) { exists = true; break; }
444 }
445 if (!exists) break;
446 }
447
448 // Create empty script
449 saveScript(name, "# New script\nprint('Hello!')\n");
450
451 // Reload and open in editor
452 loadScriptsList();
453 refreshScriptList();
454
455 // Find the new script and open it
456 for (int i = 0; i < _scriptCount; ++i) {
457 if (strcmp(_scriptNames[i], name) == 0) {
458 openScriptInEditor(i);
459 return;
460 }
461 }
462}
463
464void PythonApp::deleteScript(int idx) {
465 if (idx < 0 || idx >= _scriptCount) return;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected