// // XYBASE.VDM Christian Ziemski V 1.2 27.08.1999 // // // Helps analyzing an unknown database file (header + unilength records). // // // Usage (easy example): // // 1. Load the data file into VEDIT // 2. Load/Execute this macro // this switches to the (yet empty) structure definition // and therefore fills it with a template. // // (If you already have a definition file: load it into the next(!) // free buffer before executing the macro, switch back to the // data buffer, execute the macro and then continue with 7.) // // 5. Modify the definition manually as far as possible/desired // 6. Press Ctrl-Numpad.Enter // this switches to the data and formats it according to the definition // // 7. Switch between data and definition with Ctrl-Numpad.Enter as often as desired // or // While in data modify the header and record length online with ALT-Numpad *,/,+,-. // 8. Use the ruler (built from the field definitions) as help // (Alt-Numpad.Enter and Alt-Cursor left/right) // //-------------------------------------------------------------------- // // Buffers: // --------- // actual buffer: data // " + 1 : assumed structure definition: // title // for your own title // : --- // line must be here // nnn // length of header // nnn // length of record(s) // : --- // line must be here // nnn name // length and name of field // nnn name // length and name of field // nnn name // length and name of field // ... // more fields // //-------------------------------------------------------------------- // // Keys: Alt-NumPad * and / : increase/decrease header length (min. 0) // Alt-NumPad + and - : increase/decrease record length (min. 4) // // Alt-Cursor left/right : scroll data and ruler horizontally // (tip: switch to ruler before) // // Alt-Numpad Enter : switch between data and ruler // // Ctrl-Numpad Enter : switch between data and structure definition // (if switch to data: rebuild the form of the data) // //--------------------------------------------------------------------- Key_Add("Alt-Numpad*" , "[VISUAL EXIT] BS(#105) GL(3) #101=Num_Eval(ADVANCE) Del_Line(0) #101++ NI(#101,LEFT+NOCR) BS(#106) Call(100, 'start')", OK) Key_Add("Alt-Numpad/" , "[VISUAL EXIT] BS(#105) GL(3) #101=Num_Eval(ADVANCE) Del_Line(0) #101-- if(#101<0){#101=0 Alert} NI(#101,LEFT+NOCR) BS(#106) Call(100, 'start')", OK) Key_Add("Alt-Numpad+" , "[VISUAL EXIT] BS(#105) GL(4) #102=Num_Eval(ADVANCE) Del_Line(0) #102++ NI(#102,LEFT+NOCR) BS(#106) Call(100, 'start')", OK) Key_Add("Alt-Numpad-" , "[VISUAL EXIT] BS(#105) GL(4) #102=Num_Eval(ADVANCE) Del_Line(0) #102-- if(#102<0){#102=0 Alert} NI(#102,LEFT+NOCR) BS(#106) Call(100, 'start')", OK) Key_Add("Alt-Cursor-Right" , "[VISUAL EXIT] if(BN==#106 || BN == 35){#101=BN Char(1) #102=CN if(BN==35){BS(#106)}else{BS(35)} GC(#102,EXTRA) U BS(#101)}", OK) Key_Add("Alt-Cursor-Left" , "[VISUAL EXIT] if(BN==#106 || BN == 35){#101=BN Char(-1) #102=CN if(BN==35){BS(#106)}else{BS(35)} GC(#102,EXTRA) U BS(#101)}", OK) Key_Add("Alt-Numpad.Enter" , "[VISUAL EXIT] if(BN==#106){#102=CN BS(35) GC(#102) U} else {if(BN==35){#102=CN BS(#106) GC(#102) U}}", OK) Key_Add("Ctrl-Numpad.Enter" , "[VISUAL EXIT] if(BN==#105){BS(#106) Call(100, 'start')} else {if(BN==#106 || BN==35){BS(#105)}}", OK) //------------ :start: Config( E_CR_MODE, "Cursor positioning mode (0 - 4)", 0 ) #106 = Buf_Num // current buffer number #105 = #106 + 1 // buffer number for structure if(Win_Status('H')== -1) { // window to display the ruler Win_Split('H',1, TOP+NOBORDER) BS(35) // buffer for header Win_Attach('H') Update } BS(#105) BoF Line(1, NOERR) if(At_EoF || CC!=':'){ IT("This is an example title line: analyzing file TEST.DAT : length of header and length of records (both mandantory): 0 32 : following the fields with length and name (optional): 20 first field 20 second field # ... # # Please fill in the assumed structure here (at least lines 3 and 4!), # and press Ctrl-Numpad.Enter # (that switches back to the data and calls the macro again.) # Attention: Don't modify the structure of this definition data! # Comments must begin with a '#' in column 1 and are only allowed # past line 6 ! ) ") BoF Return } Goto_Line(3) // length of header structure #101 = Num_Eval() Goto_Line(4) // length of record #102 = Num_Eval() BS(#106) Config(F_REC_HEAD, #101, LOCAL) // Set length of header structure Config(F_F_TYPE, #102, LOCAL) // Set length of record BS(35) // header Buf_Empty(OK) BS(#105) Goto_Line(6) // the field definitions (if existing) while(! At_EoF){ if(CC=='#'){ // ignore comment lines Line(1) Continue } #103=Num_Eval(ADVANCE) // length and DOV("\NW\") RCB(103,CP,EoL_Pos) // name of field BS(35) RI(103) #98 = #103 - Reg_Size(103) // build the ruler and fit the name into it if(#98>0){ IC(32, COUNT, #98-1) } else { Del_Char(#98-1) } IT("|") BS(#105) Line(1,NOERR) } BS(35) BoF EoL IC(32,COUNT,#101-CN) // make the ruler long enough for horiz. scrolling BoF Update Buf_Switch(#105) Begin_Of_File Buf_Switch(#106) // data Begin_Of_File Return