// // FIX-INS1.VDM Christian Ziemski 22.02.2004 // // Reformats a fixed length data file by inserting columns with a choosable // character between the fields. // For easy usage it uses a manually edited ruler line. // Every character in that ruler line represents a field beginning. // The cursor has to be in that ruler line when the macro is called. // // Example: // // a) the fixed length data (line numbers only shown for better description): // // 1 123412123abcdef // 2 234556987uvwxyz // 3 ... // ... // // b) insert a ruler line (e.g. as new line 1) which marks the field limits: // // 1 x x x // 2 123412123abcdef // 3 234556987uvwxyz // 4 ... // ... // // c) position the cursor in that ruler line // d) call this macro // // e) the result: (the "_" stands for the inserted character; can be configured) // // 1 _x _x _x // 2 1234_12_123_abcdef // 3 2345_56_987_uvwxyz // 4 ... _ _ _ // ... // #103=95 // character to be inserted. eg.: 32=space; 95="_" // Note: // // From the online help of Block_Fill(): // // 'ch' cannot be a character whose current display "width" is greater // than one, e.g. the Tab character. // If 'ch' is a space and Config(E_EXP_TAB) is set to "0" - "3", // the filling is done with the optimum number of tabs and spaces. // Otherwise, only spaces are used. // // So if TABs are wanted as divider you can use this workaround: // Use a character not found in the data, e.g. "@" (64) // and do a Replace("@", "|T", BEGIN+ALL) at the end of the marco. // Save_Pos() EoF // get number of data lines (incl. ruler line) BoL if (At_EoL || (Match("|<|[|W]|>")==0)) { // if last line is empty (or only whitespace) Line(-1) // don't count it } #104=Cur_Line Restore_Pos() BOL Repeat (ALL) { Search_Block("|!|W", Cur_Pos, EoL_Pos, NOERR+ERRBREAK) Save_Pos() #105=Cur_Col Block_Fill(#103,1,#104,INSERT+LINESET+COLSET,#105,#105) Restore_Pos() Char(1) }