jw_cad 外部変形 - (500) clispで円を点に変換する -

外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。

 

clispで円を点に変換する

:clispで円を点に変換する
@echo off
if not exist %~dpn0.lisp (
  for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
    more +%%n %0 > %~dpn0.lisp
  )
)
set ci=円を残す
:set ci=円を残さない
clisp %~dpn0.lisp
goto:eof

REM #jww
REM #h1
REM #g1
REM #hc 円を選択してください
REM #e

#!この次の行からプログラムを書いてください
;円を残すか否かのフラグ
(setq ci (ext:getenv "ci"))
;円を点に変換する
( ;jwc_temp.txt へ 出力
  with-open-file (g "jwc_temp.bak" :direction :output)
( ;jwc_temp.txt から 入力
  with-open-file (f "jwc_temp.txt" :direction :input)
  (loop for line = (read-line f nil) while line do
    (setq a (regexp:regexp-split "\\s\\+" line))
    (cond 
      ( (regexp:match "^ci" line)
        (progn
          (write-line (format nil "pt ~a ~a" (nth 1 a) (nth 2 a)) g)
          (if (equal ci "円を残す")
            (write-line line g) ;円を残す
          )
        )
      )
      ( (regexp:match "^hq" line)
        (write-line "hd" g)
      )
      (t (write-line line g)
      )
    )
  )
  (close f)
)
  (close g)
)
(delete-file "jwc_temp.txt")
(rename-file "jwc_temp.bak" "jwc_temp.txt")