What is wrong with the following code for script of the texstudio
var linenumber = 0;
var keynumber = 1;
dialog = UniversalInputDialog(["a","b","c","d","e","g","h","i","j","k"],"Insert The Postfix:","com")
dialog.setWindowTitle("Insert The Postfix")
if (dialog.exec() != ""){
var postfix = dialog.get("com");
}
while(!cursor.atEnd()) {
linenumber++;
line = editor.text(linenumber);
ind = line.search('\\label{');
if (ind == -1) {
continue;
}
var env = editor.document().getLastEnvName(linenumber)
if (env.localeCompare("equation") && env.localeCompare("equation*") && env.localeCompare("eqnarry") && env.localeCompare("gather")) {
continue;
}
cursor.moveTo(linenumber, ind + 6);
// Serparating key
var str = line.substring(ind + 6, line.length);
var ind2 = str.search('}');
var key = str.substring(0, ind2);
// Checking what is the key and writing
if (!key.localeCompare("")) {
editor.write(keynumber.toString());
keynumber++;
} else if (!key.localeCompare("key")) {
cursor.deleteChar();
cursor.deleteChar();
cursor.deleteChar();
editor.write(keynumber.toString());
keynumber++;
}
}
This code is intended to label automatically equations with unique labels. Assuming that "\label{key}" is in the tex file. However, when I run texstudio stops. Is there a way to compile it outside the texstudio environment for debugging?