Hello. Can you help me with a script.
In your programm is the script that delete all spaces in the end of lines. How can I do this with the startspaces?
Sorry for my English. Hope you understand me.
Do you need a script for this (to be able to run it e.g. on each file open or save), or do you need it just one time? Because if the latter, you can simply select all text (Ctrl-A) and hit Shift-Tab a couple of times.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
// C++ script
{
string s;
int i,n;
int startx,startLine,endx,endLine;
if (Document.SelLength > 0) {
Document.GetSelection(startx,startLine,endx,endLine);
} else {
startLine = 0;
endLine = Document.LineCount - 1;
};
Document.BeginUpdate();
try
{
i = startLine;
while (i <= endLine) {
// Get line from document
s = Document.Lines[i];
// Remove spaces and write back modified line
n = 0;
while ((n <= Length(s)) && (ScriptUtils.PosAt(" ",s,n+1))) { n++; };
if (n > 0) {
// Remove spaces
Delete(s,1,n);
// Write modified line to document
Document.Lines[i] = s;
};
i++;
};
}
finally
{
Document.EndUpdate();
};
}