This post is in relation to
Post01 What I am trying to do
Post02 How to enumerate a collection:
I guess this is Post03 (why 2 digits I hear you ask...?!!)
Following on from Post02 I hacked the java code that is generated by default when you create a new button to get this:
function OnClick(clickData)
{
// --------------------------------------------------------
DOpus.ClearOutput();
// --------------------------------------------------------
var cmd = clickData.func.command;
cmd.deselect = false; // Prevent automatic deselection
// --------------------------------------------------------
DOpus.Output("000100 Selected items in " + clickData.func.sourcetab.path + ":");
if (clickData.func.sourcetab.selected.count == 0)
{
DOpus.Output(" (none)");
}
else
{
for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
{
if (eSel.item().is_dir)
{
DOpus.Output(" DIRECTORY:" + eSel.item().RealPath);
}
else
{
DOpus.Output(" FILE: " + eSel.item().RealPath);
// 01 Cut the selected files
// 02 Extract the filename stem of the last file
}
}
}
// --------------------------------------------------------
}
I want to
A1 Extract the filename stem of the last selected file (Call in F_NAME)
A2 Create a new folder with the name F_NAME
A3 Move all the selected files to the new folder.
It seems to me that the structure above is not optimum for what I want to do.
As I understand I have an object representing a collection of items.
These items are the selected files.
How might I access the last one in the first instance?
Q1 I suppose I could enumerate the collection and test each element to see if eSel.atEnd() is true?
Q2 More generally what kind of object is eSel? Some sort of "Enumerator" object?
Q3 Can anyone recommend a good URL which would document the properties and methods this object would have?
Any comments greatly appreciated as always.