Open the output window on running a script in development to see error message output by built-in JavaScript interpreter.
The commands work also with UE for Windows v14.10 with exception of command ASCIIToUTF8 which was introduced with UE for Windows v17.30 as it can be read in text file changes.txt in program files folder of UltraEdit v17.30 or any later version.
The property lineTerminator was introduced with UltraEdit for Windows v16.00. Here is a code which I used several times when a script should work also for very old versions of UltraEdit.
There must be at least 1 line with line termination selected in active file for else branch.
The else branch could be optimized by using this code:
That is faster in case of active file has UNIX or MAC line terminators and many lines are selected.
The commands work also with UE for Windows v14.10 with exception of command ASCIIToUTF8 which was introduced with UE for Windows v17.30 as it can be read in text file changes.txt in program files folder of UltraEdit v17.30 or any later version.
The property lineTerminator was introduced with UltraEdit for Windows v16.00. Here is a code which I used several times when a script should work also for very old versions of UltraEdit.
Code: Select all
// Determine line termination used currently in active file.
var sLineTerm = "\r\n";
if (typeof(UltraEdit.activeDocument.lineTerminator) == "number")
{
// The two lines below require UE v16.00 or UES v10.00 or later.
if (UltraEdit.activeDocument.lineTerminator == 1) sLineTerm = "\n";
else if (UltraEdit.activeDocument.lineTerminator == 2) sLineTerm = "\r";
}
else // This version of UE/UES does not offer line terminator property.
{
if (UltraEdit.activeDocument.selection.indexOf(sLineTerm) < 0)
{
sLineTerm = "\n"; // Not DOS, perhaps UNIX.
if (UltraEdit.activeDocument.selection.indexOf(sLineTerm) < 0)
{
sLineTerm = "\r"; // Also not UNIX, perhaps MAC.
if (UltraEdit.activeDocument.selection.indexOf(sLineTerm) < 0)
{
sLineTerm = "\r\n"; // No line terminator, use DOS.
}
}
}
}
The else branch could be optimized by using this code:
Code: Select all
var nLineTermPos = UltraEdit.activeDocument.selection.search(/\r?\n|\r/);
if (nLineTermPos >= 0)
{
sLineTerm = UltraEdit.activeDocument.selection.substr(nLineTermPos,2).replace(/^(\r?\n|\r).*$/,"$1");
}
Best regards from an UC/UE/UES for Windows user from Austria