#script
@script JScript
function OnClick(clickData)
{
var tab = clickData.func.sourcetab;
var cmd = clickData.func.command;
cmd.deselect = false;
var vecDeselect = DOpus.Create.Vector();
var blobBOM = DOpus.Create.Blob(0xEF,0xBB,0xBF);
var blobFile = DOpus.Create.Blob();
for (var eSel = new Enumerator(clickData.func.sourcetab.selected_files); !eSel.atEnd(); eSel.moveNext())
{
var item = eSel.item();
var file = item.Open("r", tab);
if (file.error == 0 &&
file.Read(blobFile, 3) == 3 &&
file.error == 0 &&
blobBOM.Compare(blobFile) == 0)
{
blobFile.Free();
file.Read(blobFile);
if (file.error == 0)
{
file.Close();
file = item.Open("wt", tab);
if (file.error == 0)
{
file.Write(blobFile);
file.Close();
vecDeselect.push_back(item);
}
}
}
}
if (vecDeselect.size > 0)
{
cmd.ClearFiles();
cmd.AddFiles(vecDeselect);
cmd.RunCommand("Select DESELECT FROMSCRIPT");
}
}
==SCRIPT RESOURCES
<resources>
<resource name="TestDialog" type="dialog">
<dialog fontsize="8" height="180" lang="english" resize="yes" standard_buttons="ok" title="My Super Special Script Dialog" width="168">
<control halign="left" height="8" name="static1" title="Name:" type="static" width="20" x="6" y="8" />
<control halign="left" height="12" name="edit1" resize="w" tip="Enter your name" type="edit" width="126" x="36" y="6" />
<control halign="left" height="8" name="static2" title="Age:" type="static" width="20" x="6" y="62" />
<control halign="left" height="12" name="edit2" number="yes" title="Edit Control" type="edit" updown="yes" width="42" x="36" y="60" />
<control height="10" name="radio1" title="Human Years" type="radio" width="64" x="36" y="78" />
<control height="10" name="radio2" title="Cat Years" type="radio" width="64" x="36" y="90" />
<control height="10" name="radio3" title="Dog Years" type="radio" width="64" x="36" y="102" />
<control halign="left" height="8" name="static3" title="Species:" type="static" width="30" x="6" y="27" />
<control height="40" name="combo1" type="combo" width="126" x="36" y="24">
<contents>
<item text="Human Being" />
<item text="Domestic Cat" />
<item text="Wild Cat" />
<item text="Domestic Dog" />
<item text="Wolf" />
<item text="Pigeon" />
</contents>
</control>
<control height="10" name="check1" title="Unsure" type="check" width="64" x="36" y="42" />
<control halign="left" height="8" name="static4" resize="y" title="Remember your TPS reports!" type="static" width="102" x="6" y="168" />
<control height="36" name="listbox1" resize="wh" type="listbox" width="126" x="36" y="120" />
</dialog>
</resource>
<resource type="strings">
<strings lang="francais">
<string id="hello" text="Bonjour!" />
</strings>
<strings lang="deutsch">
<string id="hello" text="Guten Tag!" />
</strings>
<strings lang="english">
<string id="hello" text="Hello
World" />
</strings>
</resource>
</resources>