(defun C:dialog_shtamp_editor_gost ( / dcl_id patch patch_blank temp n list_cell cell)
(geo_tools-help "dialog_shtamp_editor_gost")
  (setq patch_blank (strcat *geo_tools_user_dat_dir* "\\template\\blank.sht"))
  (setq dcl_id (geo-tools-load-dialog "d_shtamp_gost"))
  (new_dialog "d_shtamp_gost" dcl_id)
;;;  (setq patch (file_dat_r_g_w "r" "patch_sh" nil))
  (setq patch (PL:GetD "patch_current_shtamp"))
  (if (eq patch nil) (setq patch patch_blank))
  (if (not (file_check patch))
      (setq patch patch_blank))
  (setq list_cell(file_read_to_list patch))
  (set_tile "top" (strcat "Редактор шаблонов штампа ["(vl-filename-base patch)"]"))
  (dialog_set_the_tile_all list_cell)
  (dialog_action_the_tile_all)
  (action_tile "new" "(setq patch patch_blank)(setq list_cell(file_read_to_list patch))
  (setq n 1)
  (repeat (length list_cell)
    (set_tile (strcat \"c\" (itoa n)) (nth  (1- n) list_cell))
    (setq n (1+ n)))
  (set_tile \"top\" (strcat \"Редактор шаблонов штампа [\"(vl-filename-base patch)\"]\"))")
  (action_tile "open" "(setq temp(getfiled \"Выбор файла\" (getvar \"DWGPREFIX\") \"sht\" 0))
  (if temp
(progn
(setq patch temp)
  (setq list_cell(file_read_to_list patch))
    (setq n 1)
  (repeat (length list_cell)
    (set_tile (strcat \"c\" (itoa n)) (nth  (1- n) list_cell))
    (setq n (1+ n)))
  (set_tile \"top\" (strcat \"Редактор шаблонов штампа [\"(vl-filename-base patch)\"]\"))))
    ")
  (action_tile "save" "(if (/= patch patch_blank)
  (file_write_list_to_file patch list_cell)
  (progn (setq temp(getfiled \"Сохранить как...\" (strcat(getvar \"DWGPREFIX\")
(substr (getvar \"DWGNAME\") 1 (-(strlen (getvar \"DWGNAME\"))4))) \"sht\" 1))
(if temp
(progn
(setq patch temp)
    (file_write_list_to_file patch list_cell)
    (set_tile \"top\" (strcat \"Редактор шаблонов штампа [\"(vl-filename-base patch)\"]\"))))))
    ")
  (action_tile "save_as" "(setq temp(getfiled \"Сохранить как...\" (strcat(getvar \"DWGPREFIX\")
(substr (getvar \"DWGNAME\") 1 (-(strlen (getvar \"DWGNAME\"))4))) \"sht\" 1))
(if temp
(progn
(setq patch temp)
    (file_write_list_to_file patch list_cell)
    (set_tile \"top\" (strcat \"Редактор шаблонов штампа [\"(vl-filename-base patch)\"]\"))))
    ")
  (if (eq (start_dialog) 0)
    (unload_dialog dcl_id)
    (progn
      (unload_dialog dcl_id)
      (if (/= patch patch_blank)
	(file_write_list_to_file patch list_cell)
	(progn
	  (setq temp(getfiled "Сохранить как..."
			      (strcat(getvar "DWGPREFIX")
				     (substr (getvar "DWGNAME") 1 (-(strlen (getvar "DWGNAME"))4)))
			      "sht" 1))
	  (if temp
	    (progn
	      (setq patch temp)
	      (file_write_list_to_file patch list_cell)
	      ))))
;;;      (file_dat_r_g_w "w" "patch_sh" patch)
      (PL:SetD "patch_current_shtamp" patch)
      )
    )
  (princ)
  )
