("9001 2" "9002 4" "9003 7" "9004 8" "9005 0")
((9001 2) (9002 4) (9003 7) (9004 8) (9005 0))
(defun test (key value / filename file lst lst-new rec_txt) (defun rec_txt (txt /) (if txt (cons (read (strcat "(" txt ")")) (rec_txt (read-line file)) ) ;_ end of cons ) ;_ end of if ) ;_ end of defun (if (setq filename (getfiled "Выберите файл" "" "dat" 8)) (progn (setq file (open filename "r") lst (rec_txt (read-line file)) file (open filename "w") lst-new (subst (list key value) (assoc key lst) lst) ) ;_ end of setq (foreach item lst-new (write-line (strcat (itoa (car item)) " " (itoa (cadr item))) file ) ;_ end of write-line ) ;_ end of foreach (close file) (princ (strcat "Информация сохранена в файле : " filename)) ) ;_ end of progn (princ "Файл не выбран") ) ;_ end of if (princ) ) ;_ end of defun ;;;(test 9002 100)
(defun test (file lst / F L S) (setq f (open file "r") lst (mapcar (function (lambda (a) (cons (atoi a) a))) lst) ) ;_ setq (while (setq s (read-line f)) (if (assoc (atoi s) lst) (setq l (cons (cdr (assoc (atoi s) lst)) l)) (setq l (cons s l)) ) ;_ if ) ;_ while (close f) (setq f (open file "w")) (foreach a (reverse l) (write-line a f)) (close f) )
(test "D:\\1.txt" '("9001 33" "9002 1" "9003 9" "9004 3" "9005 2"))