Here the complete macro (a bit optimized and documented):
Since the HTML converter of WebBoard reformats the macro I attached it as file too.
//
// SORTLENGTH.VDM F.Heberlein and Ch.Ziemski 12.10.2001
// last change 13.10.2001
//
// Sorts a file by line length
//
Num_Push(1,1) // save the used register
BOF
while(!At_Eof){ //
EOL() //
#1=Cur_Col()-1 // get length of every line
BOL() //
Num_Ins(#1, NOCR+FILL+FORCE) // and write it as 10 digit number at line begin
Ins_Text(" ") //
Line(1, NOERR) // handle possible last line without CR/LF too
}
Num_Pop(1,1) // restore the used register
Sort_Merge("1,11", 0, File_Size) // sort the whole text (by the leading number)
// BOF()
// while(!At_Eof){ //
// BOL() //
// Del_Char(11) // remove the numbers again
// Line(1)
// }
// or shorter (and faster for big files):
End_Of_File
Line(-1)
Del_Block(0, Cur_Pos+11, COLUMN) // remove the numbers again
Christian
|
|