(defun C:add_description (/ command-list description flag-11 flag-41 list-file list-file-txt list-point new-list-file-txt number put-file-raw put-file-txt temp code-list delimetr new-list-point)
  (setq command-list(dialog_add_description))
  (cond
    ((= (cadr(assoc "format-file-tah" command-list)) "0");SDR
     (if(setq put-file-raw (getfiled "Выбор SDR файла" (getvar "DWGPREFIX")  "SDR;txt;*" 0))
       (progn
	 (setq list-file (file_read_to_list put-file-raw))
	 (foreach x list-file
	   (if (=(substr x 1 4)"09F1")
	     (setq list-point (append list-point (list(list (vl-string-trim" "(substr x 21 16))(vl-string-trim" "(substr x 85 16))))))
	     )
	   )
	 )
       )
     )
    ((= (cadr(assoc "format-file-tah" command-list)) "1");GSI файла, описание во второй строке
     (if(setq put-file-raw (getfiled "Выбор GSI файла" (getvar "DWGPREFIX")  "GSI;txt;*" 0))
       (progn
	 (setq list-file (file_read_to_list put-file-raw))
	 (foreach x list-file
	   (if (and flag-11(=(substr x 1 3)"*41"))
	     (progn
	       (setq list-point (append list-point (list(list number(vl-string-left-trim"0"(substr x 9 16))))))
	       (setq flag-11 nil
		     number "")
	       )
	     )
	   (if (=(substr x 1 3)"*11")
	     (progn
	       (setq number (vl-string-left-trim"0"(substr x 9 16)))
	       (setq flag-11 T)
	       )
	     )
	   )
	 )
       )
     )
    ((= (cadr(assoc "format-file-tah" command-list)) "2");GSI файла, описание в первой строке
     (if(setq put-file-raw (getfiled "Выбор GSI файла" (getvar "DWGPREFIX")  "GSI;txt;*" 0))
       (progn
	 (setq list-file (file_read_to_list put-file-raw))
	 (foreach x list-file
	   (if (and flag-41(=(substr x 1 3)"*11"))
	     (progn
	       (setq list-point (append list-point (list(list(vl-string-left-trim"0"(substr x 9 16))description))))
	       (setq flag-41 nil
		     description "")
	       )
	     )
	   (if (=(substr x 1 3)"*41")
	     (progn
	       (setq description (vl-string-left-trim"0"(substr x 9 16)))
	       (setq flag-41 T)
	       )
	     )
	   )
	 )
       )
     )
    )
  (if (= (cadr(assoc "replace-codes" command-list)) "1")
    (progn
      (setq list-file (file_read_to_list (strcat *geo_tools_root_dir* "\\data\\codes\\Цифры.txt")))
      (setq delimetr (car list-file))
      (foreach x (cdr list-file)
	(setq code-list (append code-list (list (convert-string-to-list-be-delimiter x "\t"))))
	)
      (foreach x list-point
	(if (setq description(cadr(assoc (nth 1 x)code-list)))
	  (setq new-list-point (append new-list-point (list (list (nth 0 x)description))))
	  (setq new-list-point (append new-list-point (list x)))
	  )
	)
      (setq list-point new-list-point)
      )
    )
  (if (and(>(length list-point)0)(setq put-file-txt (getfiled "Выбор файла уравненных координат" (getvar "DWGPREFIX")  "txt;*" 0)))
    (progn
      (setq list-file-txt (file_read_to_list put-file-txt))
      (foreach x list-file-txt
	(setq temp (convert-string-to-list-be-delimiter x ","))
	(if (setq description (cadr(assoc (nth 0 temp)list-point)))
	  (setq new-list-file-txt (append new-list-file-txt (list (convert-list-to-string-be-delimiter (list (nth 0 temp)(nth 1 temp)(nth 2 temp)(nth 3 temp)description)","))))
	  (setq new-list-file-txt (append new-list-file-txt (list x)))
	  )
	)
      (file_write_list_to_file (strcat (vl-filename-directory put-file-txt)"\\"(vl-filename-base put-file-txt)"_"(vl-filename-extension put-file-txt)) new-list-file-txt)
      )
    )
  (princ)
  )

(defun dialog_add_description (/ command-list dcl_id)
  (setq command-list (vlax-ldata-get"geo_tools_dictionary" "dialog_add_description"))
  (setq patch-codes (strcat *geo_tools_root_dir* "\\data\\codes"))
  (if (eq command-list nil)
    (setq command-list (list (list "format-file-tah" "1")(list "replace-codes" "1")(list "codes-type" "1"))))
  (setq dcl_id (geo-tools-load-dialog "dialog_add_description"))
  (new_dialog "dialog_add_description" dcl_id)
  
  (foreach x command-list
    (set_tile (car x)(cadr x))
    )
  (if (= (cadr(assoc "replace-codes" command-list)) "1")
	 (mode_tile "codes-type" 0)
	 (mode_tile "codes-type" 1)
	 )
  (action_tile "format-file-tah"
    (vl-prin1-to-string
      '(progn
	(setq command-list (put-item-by-name-in-list command-list "format-file-tah" $value))
	)))
  
  (action_tile "replace-codes"
    (vl-prin1-to-string
      '(progn
	(setq command-list (put-item-by-name-in-list command-list "replace-codes" $value))
	(if (= $value "1")
	 (mode_tile "codes-type" 0)
	 (mode_tile "codes-type" 1)
	 )
	)))
   (action_tile "codes-type"
    (vl-prin1-to-string
      '(progn
	(setq command-list (put-item-by-name-in-list command-list "codes-type" $value))
	)))
  (if (/= (start_dialog) 0)
    (progn
      (vlax-ldata-put"geo_tools_dictionary" "dialog_add_description"command-list)
      command-list
      )
    )
  )














;;;(defun C:add-description-num-first (/ put-file-gsi put-file-txt flag-11 number description list-point list-file-txt new-list-file-txt temp list-file)
;;;; добавление описания (примечания) в файл формата P,E,N,Z,D из GSI файла, описание во второй строке
;;;  (if(setq put-file-gsi (getfiled "Выбор GSI координат" (getvar "DWGPREFIX")  "GSI;txt;*" 0))
;;;    (progn
;;;      (setq list-file (file_read_to_list put-file-gsi))
;;;      (foreach x list-file
;;;	(if (and flag-11(=(substr x 1 3)"*41"))
;;;	  (progn
;;;	    (setq list-point (append list-point (list(list number(vl-string-left-trim"0"(substr x 9 16))))))
;;;	    (setq flag-11 nil
;;;		  number "")
;;;	    )
;;;	  )
;;;	(if (=(substr x 1 3)"*11")
;;;	  (progn
;;;	    (setq number (vl-string-left-trim"0"(substr x 9 16)))
;;;	    (setq flag-11 T)
;;;	    )
;;;	  )
;;;	)
;;;      )
;;;    )
;;;  (if (and(>(length list-point)0)(setq put-file-txt (getfiled "Выбор файла уравненных координат" (getvar "DWGPREFIX")  "txt;*" 0)))
;;;    (progn
;;;      (setq list-file-txt (file_read_to_list put-file-txt))
;;;      (foreach x list-file-txt
;;;	(setq temp (convert-string-to-list-be-delimiter x ","))
;;;	(if (setq description (cadr(assoc (nth 0 temp)list-point)))
;;;	  (setq new-list-file-txt (append new-list-file-txt (list (convert-list-to-string-be-delimiter (list (nth 0 temp)(nth 1 temp)(nth 2 temp)(nth 3 temp)description)","))))
;;;	  (setq new-list-file-txt (append new-list-file-txt (list x)))
;;;	  )
;;;	)
;;;      (file_write_list_to_file (strcat (vl-filename-directory put-file-txt)"\\"(vl-filename-base put-file-txt)"_"(vl-filename-extension put-file-txt)) new-list-file-txt)
;;;      )
;;;    )
;;;;;;  (princ list-point)
;;;  (princ)
;;;  )


;;;(defun C:add-description-num-two (/ put-file-gsi put-file-txt flag-41 description list-point list-file-txt new-list-file-txt temp)
;;;; добавление описания (примечания) в файл формата P,E,N,Z,D из GSI файла, описание перед номером
;;;  (if(setq put-file-gsi (getfiled "Выбор GSI координат" (getvar "DWGPREFIX")  "GSI;txt;*" 0))
;;;    (progn
;;;      (setq list-file (file_read_to_list put-file-gsi))
;;;      (foreach x list-file
;;;	(if (and flag-41(=(substr x 1 3)"*11"))
;;;	  (progn
;;;	    (setq list-point (append list-point (list(list(vl-string-left-trim"0"(substr x 9 16))description))))
;;;	    (setq flag-41 nil
;;;		  description "")
;;;	    )
;;;	  )
;;;	(if (=(substr x 1 3)"*41")
;;;	  (progn
;;;	    (setq description (vl-string-left-trim"0"(substr x 9 16)))
;;;	    (setq flag-41 T)
;;;	    )
;;;	  )
;;;	)
;;;      )
;;;    )
;;;  (if (and(>(length list-point)0)(setq put-file-txt (getfiled "Выбор файла уравненных координат" (getvar "DWGPREFIX")  "txt;*" 0)))
;;;    (progn
;;;      (setq list-file-txt (file_read_to_list put-file-txt))
;;;      (foreach x list-file-txt
;;;	(setq temp (convert-string-to-list-be-delimiter x ","))
;;;	(if (setq description (cadr(assoc (nth 0 temp)list-point)))
;;;	  (setq new-list-file-txt (append new-list-file-txt (list (convert-list-to-string-be-delimiter (list (nth 0 temp)(nth 1 temp)(nth 2 temp)(nth 3 temp)description)","))))
;;;	  (setq new-list-file-txt (append new-list-file-txt (list x)))
;;;	  )
;;;	)
;;;      (file_write_list_to_file (strcat (vl-filename-directory put-file-txt)"\\"(vl-filename-base put-file-txt)"_"(vl-filename-extension put-file-txt)) new-list-file-txt)
;;;      )
;;;    )
;;;;;;  (princ list-point)
;;;  (princ)
;;;  )

;;;(defun C:add-description-for-sdr (/ put-file-sdr put-file-txt flag-11 number description list-point list-file-txt new-list-file-txt temp list-file)
;;;; добавление описания (примечания) в файл формата P,E,N,Z,D из SDR файла
;;;  
;;;  (if (and(>(length list-point)0)(setq put-file-txt (getfiled "Выбор файла уравненных координат" (getvar "DWGPREFIX")  "txt;*" 0)))
;;;    (progn
;;;      (setq list-file-txt (file_read_to_list put-file-txt))
;;;      (foreach x list-file-txt
;;;	(setq temp (convert-string-to-list-be-delimiter x ","))
;;;	(if (setq description (cadr(assoc (nth 0 temp)list-point)))
;;;	  (setq new-list-file-txt (append new-list-file-txt (list (convert-list-to-string-be-delimiter (list (nth 0 temp)(nth 1 temp)(nth 2 temp)(nth 3 temp)description)","))))
;;;	  (setq new-list-file-txt (append new-list-file-txt (list x)))
;;;	  )
;;;	)
;;;      (file_write_list_to_file (strcat (vl-filename-directory put-file-txt)"\\"(vl-filename-base put-file-txt)"_"(vl-filename-extension put-file-txt)) new-list-file-txt)
;;;      )
;;;    )
;;;;;;  (princ list-point)
;;;  (princ)
;;;  )