#9796
Stefan
Participant

No useful script. Just an little lesion.
Loop virtually through only the selected lines in file.
The cursor will not move!
We access each line by its number only.

– – –

Best to learn is to do some lessons.
So i will show my steps creating an macro for others.

I am not saying that this is the best way to do it,
it is just an start.

If you have an better way to do it, or other
suggestions, just reply :-)


////Loop through Selection

////Object handling to save always typing of 'document.selection':
var d = document;
var s = d.selection;


////////Get the selected text to work on:
////////(Depends if already something is selected or not)
if (s.IsEmpty)
{
////If document.selection is empty:
vWasAnSelection = false;

////Alternative one
//alert("Nothing selected, script quits. Please select and start again.");
//quit();

////Alternative two
alert("Nothing selected, script will select whole text for you.");
s.SelectAll();

}else{

////If there was an selection already:
vWasAnSelection = true;
alert("Selected text to work on: n" + s.text);
}



////////Get start and end line of the selection:
///Returns the line number of the top of the selection.
FirstSelLine = s.GetTopPointY(eePosLogical);
///Returns the line number of the bottom of the selection.
LastSelLine = s.GetBottomPointY(eePosLogical);



////For Each Line In SelectedLineS Do:
for( Line = FirstSelLine; Line <= LastSelLine; Line++)
{
//// <<< Your code here >>>
//// Here an simple example:
ret = Confirm(d.GetLine(Line));
if (ret == false) {if (!vWasAnSelection){s.Collapse();} Quit();}
}


////If there was no selection do an UnSelectAll at the end:
if (!vWasAnSelection) s.Collapse();