PRO cmdb_order ; Uses order file to re-arrange the CMDB data in common @cmdb_common @cmdb_integer_columns ; The combination cmdb_file_path + cmdb_order_file gives the ; cmdb order file to be read in. ; Make sure cmdb is loaded ; if N_ELEMENTS(cmdb_lines) LE 0 then begin print, '*** cmdb file not loaded ***' RETURN end if n_elements(cmdb_order_file) LE 0 then cmdb_order_file = '961002.order' ; --- Read in the CMDB order file n_max = 5000 ;maximum entries line='' lines = STRARR(n_max) id = -1 OPENR, cmdb_unit, cmdb_file_path+cmdb_order_file, /GET_LUN WHILE(NOT EOF(cmdb_unit)) do begin READF, cmdb_unit, line ;; ; skip lines starting with a ; ;; if (strpos(line,';') NE 0) then begin id=id+1 lines(id) = STRCOMPRESS(line,/REMOVE_ALL) ;; end end CLOSE, cmdb_unit FREE_LUN, cmdb_unit n_rows = id+1 order_lines = lines(0:id) print, '' print, ' cmdb_order: found '+STRING(n_rows,FORMAT='(I4)')+$ ' lines in '+cmdb_order_file print, '' ; Now order the measurements in common for ir=0,n_rows-1 do begin ; find the measurement in the cmdb this_one=where(cmdb_fields(*,c_id) EQ order_lines(ir),nfound) if nfound EQ 1 then begin ; OK, add this to ordered indices if ir EQ 0 then order_indices = [this_one(0)] else $ order_indices = [order_indices,this_one(0)] end else begin ; didn't find this measurement? print, '* didnt find '+order_lines(ir)+' in cmdb?' end end ; Now reorder the data base inter_lines = cmdb_lines cmdb_lines = inter_lines(order_indices) inter_fields = cmdb_fields cmdb_fields = inter_fields(order_indices,*) RETURN END