// // TAB2FIX-4.VDM Christian Ziemski 22.02.2004 // 25.08.2004 // // // Converts TAB separated data into fixed length data // (Based on CSV2TAB.VDM) // // To overcome VEDITs current limits regarding number of TABs this // macro does things manually (slower). // BoF Search("|T", BEGIN+NOERR) // any TAB separators found? if (EM) { return // no? then nothing to do } // simple check for number of TABs, (assuming equal lines) BoF #103=0 while (Search_Block("|T", Cur_Pos, EoL_Pos, ADVANCE+NOERR)>0) { #103++ } if (#103>100) { Num_Str(#103, 103) #104=Dialog_Input_1(104, "`TAB2FIX.VDM`, `Sorry, this macro only supports max. 100 TABs.`, `The current file seems to have |@(103) TABs in a line.`, `[&Ok]`",APP+CENTER,0,0) return } #106=Config( E_EXP_TAB, "Expand key with spaces (*)", 1 ) Num_Push(1,100) // save used registers for (#103=1; #103<101; #103++) { // set them all to zero #@103=0 } // determine field widths BoF while (! At_EoF) { // loop through all data lines #103=1 // counter for TABs #104=1 // current character position in line while (#103 < 101) { // loop through current line and Search_Block("|T", Cur_Pos, EoL_Pos, NOERR+ERRBREAK) #105 = Cur_Pos-BoL_Pos-#104+1 // length of current field #@103 = Max(#@103, #105) // find max. length of n'th field Char(1) #104=Cur_Pos-BoL_Pos+1 // current character position in line #103++ } Line(1, NOERR) } // reformat fields according to their individual max. width BoF while (! At_EoF) { // loop through all data lines again #103=1 // counter/pointer #104=1 // current cursor column while ((#103 <100) && (#@103 != 0)) { Search("|T", NOERR+ERRBREAK) Del_Char(1) #105=#@103+#104+1 // incl. one character between fields Ins_Indent(#105) #104 = #105 #103++ } if (Error_Match) { break } } Num_Pop(1,100) // restore used registers Config( E_EXP_TAB, "Expand key with spaces (*)", #106 ) BoF