Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
40
Task/Align-columns/Vedit-macro-language/align-columns.vedit
Normal file
40
Task/Align-columns/Vedit-macro-language/align-columns.vedit
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
RS(10, "$") // Field separator
|
||||
#11 = 1 // Align: 1 = left, 2 = center, 3 = right
|
||||
|
||||
// Reset column widths. Max 50 columns
|
||||
for (#1=40; #1<90; #1++) { #@1 = 0 }
|
||||
|
||||
// Find max width of each column
|
||||
BOF
|
||||
Repeat(ALL) {
|
||||
for (#1=40; #1<90; #1++) {
|
||||
Match(@10, ADVANCE) // skip field separator if any
|
||||
#2 = Cur_Pos
|
||||
Search("|{|@(10),|N}", NOERR) // field separator or end of line
|
||||
#3 = Cur_Pos - #2 // width of text
|
||||
if (#3 > #@1) { #@1 = #3 }
|
||||
if (At_EOL) { Break }
|
||||
}
|
||||
Line(1, ERRBREAK)
|
||||
}
|
||||
|
||||
// Convert lines
|
||||
BOF
|
||||
Repeat(ALL) {
|
||||
for (#1=40; #1<90; #1++) {
|
||||
#2 = Cur_Pos
|
||||
Search("|{|@(10),|N}", NOERR)
|
||||
if (At_EOL==0) { Del_Char(Chars_Matched) }
|
||||
#3 = #@1 - Cur_Pos + #2 // number of spaces to insert
|
||||
#4 = 0
|
||||
if (#11 == 2) { #4 = #3/2; #3 -= #4 } // Center
|
||||
if (#11 == 3) { #4 = #3; #3 = 0 } // Right justify
|
||||
Set_Marker(1, Cur_Pos)
|
||||
Goto_Pos(#2)
|
||||
Ins_Char(' ', COUNT, #4) // add spaces before the word
|
||||
Goto_Pos(Marker(1))
|
||||
Ins_Char(' ', COUNT, #3+1) // add spaces after the word
|
||||
if (At_EOL) { Break }
|
||||
}
|
||||
Line(1, ERRBREAK)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue