Scripting Method: character lost during script storage/reload

Advanced Renamer forum
#1 : 22/11-12 19:01
NomenEtOmen
NomenEtOmen
Posts: 29
today i have installed the portable version 3.53 on win7/32bit.
i have written an renaming script and saved with the offered saving-method into an aren-file (into the default batchMethods-SubFolder). After reloading this method there was any characters lost, the script was faulty.

here this faulty script:
<code>
/*
list of words: last word to front, separated with ,
words words word -> word, words words
*/
var oName = item.name; //original name
var nName = " //new name
var last = " //ast word
var help = "
var sSep = ", //the separator after first word

//processing error when name contains .
//workaround: mask . with other char: ~
var bWorkAround = 1; //workaroung active
if (bWorkAround && oName.indexOf(".")>=0){
oName = oName.replace(/\./g,"~");
return; //de-activate renaming for .
}

//algorithm selection
var algorithm = "split //substr extract with substr-technology
//split use split and rebuild
if (algorithm=="substr"){
/* substr-index-variante */
var nLastIndex = oName.lastIndexOf(" ");
if (nLastIndex<=0) {
//no space found
return;
}
last = oName.substring(nLastIndex);
nName = last + sSep + " " + oName.substr(0,nLastIndex);


} else if (algorithm=="split"){
/* split-variante */
var comp = oName.split(" ");
if (comp.length<=1) {
//no spliting
return;
}
//it has splitted :-)
last = comp.pop() + sSep;
comp.unshift(last);
nName = comp.join(" ");

} else {
//unsigned algorithm -> error
return;
}

//tried workaround: de-masking . with ~
if (bWorkAround && nName.indexOf("~")>=0){
nName = nName.replace(/~/g,".");
}

//script-end: new name
//item.newName = nName;
return nName;
</code>


As you can see, after storage/reload in the var-section the declaration closure <string>";</string> will be lost:
in the original it is:
<code>
...
var nName = ""; //new name
var last = ""; //ast word
var help = "";
var sSep = ","; //the separator after first word
...
</code>


22/11-12 19:01 - edited 22/11-12 19:02
#2 : 23/11-12 20:39
Kim Jensen
Kim Jensen
Administrator
Posts: 883
Reply to #1:
You are right "; will get chopped. I will make sure that gets fixed. Unfortunately it will result in backwards incompatibility: A method file saved with the next version which includes a "; combination, will not be readable to any prior version. But that is a incompatibility risk I am willing to take.


23/11-12 20:39
#3 : 26/11-12 18:07
NomenEtOmen
NomenEtOmen
Posts: 29
Reply to #2:
fine.


26/11-12 18:07