// // UNIQUE.VDM C.Z. 28.11.2000 // 29.11.2000 // // // // // BoF // Get the columns of the key field if(BB!=-1 && BE!= -1){ #99=CP GP(BB) #11=Cur_Col // left column GP(BE) #12=Cur_Col-1 // right key column GP(#99) }else{ #99=Dialog_Input_1(11,"`Define key field`, ` Please input the beginning and end column \n of the sort key (devided by space)`, `??&Columns:`", APP+CENTER, 0, 0) if(#99==0){ return } #99=BN Buf_Switch(Buf_Free(EXTRA)) RI(11) BoF #11=Num_Eval(ADVANCE) // left key column #12=Num_Eval(ADVANCE) // right key column BQ(OK) BS(#99) } // index field to save the original order #99=1 while(! At_EoF){ IT("@") NI(#99, FORCE+FILL+NOCR) IT("@ ") #99++ Line(1, NOERR+ERRBREAK) } #14 = #11+13 // new position of key field #15 = #12+13 // #16 = #12-#11 // size of key field - 1 BoF // sort lines by key field Sort(0, EoB_Pos, KEYCOLS, #14, #15) // delete all lines with duplicate key field, only the first one remains Goto_Col(#14) RCB(15, CP, CP + #16) Line(1,NOERR+ERRBREAK) repeat(ALL){ Goto_Col(#14) RCB(16, CP, CP + #16) if(Reg_Compare(15, @(16)) != 0){ // if not equal Reg_Set(15,@16) // prepare next Line(1, NOERR+ERRBREAK) }else{ BoL // if equal Del_Line(1) // delete second line } } Sort(0, EoB_Pos, KEYCOLS, 1, 13) // sort lines in the original order Del_Block(0, EoB_Pos, COLSET, 1, 13) // delete index field BoF