Hi, there:
I've a script that will repeat till there's no more occurrence of a pattern. But recently I found it cannot complete it.
The script just removes any spaces between "!", "?" or ".".
It works when I do it manually by replace dialog box with parameter of "([!?.])\s+([!?.])" and "\1\2".
But with UEStudio v14.00, the "do loop" of this script will just run once, because the return value of findReplace.replace() is always "false". And that is different from the older version (UE 14 or UES 6).
I've temporary fixed the problem with following script, but it sucks. I'm sure that it's bug of UEStudio v14.10.
Reason 1:
The above script worked with older version of UE 14.xx and UES 6.xx.
Reason 2:
With option findReplace.replaceAll=true; the command findReplace.replace() returns always false, no matter there a match/replace occurs (in current version).
Reason 3:
With option findReplace.replaceAll=false; the command findReplace.replace(); returns true, if a match/replace occurs.
(But, it will not warp to top(), so I have to add scripting command top(); at right places.)
Please help, thanks.
I've a script that will repeat till there's no more occurrence of a pattern. But recently I found it cannot complete it.
The script just removes any spaces between "!", "?" or ".".
It works when I do it manually by replace dialog box with parameter of "([!?.])\s+([!?.])" and "\1\2".
But with UEStudio v14.00, the "do loop" of this script will just run once, because the return value of findReplace.replace() is always "false". And that is different from the older version (UE 14 or UES 6).
Code: Select all
function Srt_Norm() {
var cnt;
with (UltraEdit.activeDocument) {
findReplace.replaceAll=true;
findReplace.matchCase=true;
findReplace.regExp=true;
top();
do {
cnt = findReplace.replace("([!?.])\\s+([!?.])", "\\1\\2");
// UltraEdit.outputWindow.write(cnt+"\r\n");
} while (cnt);
}
}
UltraEdit.insertMode();
if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
UltraEdit.unixReOn();
UltraEdit.activeDocument.hexOff();
Srt_Norm();
Reason 1:
The above script worked with older version of UE 14.xx and UES 6.xx.
Reason 2:
With option findReplace.replaceAll=true; the command findReplace.replace() returns always false, no matter there a match/replace occurs (in current version).
Reason 3:
With option findReplace.replaceAll=false; the command findReplace.replace(); returns true, if a match/replace occurs.
(But, it will not warp to top(), so I have to add scripting command top(); at right places.)
Code: Select all
do {
top();
findReplace.replaceAll=false;
cnt = findReplace.replace("([!?.])\\s+([!?.])", "\\1\\2");
if (cnt) {
findReplace.replaceAll=true;
findReplace.replace("([!?.])\\s+([!?.])", "\\1\\2");
}
// UltraEdit.outputWindow.write(cnt+"\r\n");
} while (cnt);