// // TAB2FIX.VDM Christian Ziemski 22.02.2004 // 19.08.2004 // // // Converts TAB separated data into fixed length data // (Based on CSV2TAB.VDM) // // Note: // Up to VEDIT 6.11 there is a limitation of 32 TABs up to column 254. // That is enhanced to ~100 TABs up to around column 65000 // in the upcoming version of VEDIT. // // 6.12: // Up to column 65535, but still restricted number of different sized TABs // (There are more *Equal sized* TAbs possible, but not yet implemented here.) // 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>32) { Num_Str(#103, 103) Dialog_Input_1(104, "`TAB2FIX.VDM`, `Sorry, but this macro only supports 32 TABs per line (yet).`, `The current file has |@(103) TABs in a line.`, `[&Ok]`",APP+CENTER,0,0) return } Num_Push(1,32) // save used registers for (#103=1; #103<33; #103++) { // set them all to zero #@103=0 } BoF while (! At_EoF) { // loop through all data lines #103=1 // counter for TABs #104=1 // current character position in line while (#103 < 33) { // 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) } //? #1 #2 #3 #4 #5 ? Out_Reg(103) // build the string of new TABulator positions #104=1 // current cursor column for (#103=1; #103<33; #103++) { // loop through all found data fields if (#@103==0) { break } #105=#@103+#104+1 // incl. one character between fields (needed!) Num_Type(#105, NOCR) #104 = #105 } Out_Reg(CLEAR) if(#103==2) { // if only one Tab => extra handling Out_Reg(103) // this position 2 times Num_Type(#1, NOCR) Num_Type(#1, NOCR) // (otherwise it would be Out_Reg(CLEAR) // interpreted as distance !) } Reg_Set(103,"Config_Tab(", INSERT) // command begin -> R.103 Reg_Set(103,")", APPEND) // command end -> R.103 Call(103) // execute the built command Detab_Block(0, File_Size) // TABs to spaces Num_Pop(1,32) // restore used registers BoF