本帖最后由 lee50310 于 2022-6-6 09:09 编辑
將上面2個檔 demo.lsp及demo.dcl 放在 d:\demo 路徑下
執行 DCL2LSP程式 選擇要轉換的dcl檔 選擇d:\demo\ 路徑下的 demo.dcl
轉換為 lisp
轉換成功後會在該目錄下 產生一個 DCL_demo.lsp 檔
依照下面的步驟操作
- 編輯DCL_demo.lsp ,demo.lsp
- (1)將 DCL_demo.lsp 內容複製 並 貼在 demo.lsp 程式內容的上方
- (2)並將
- ;<<<<<< 設定 DCL >>>>>>
-
- (vl-load-com) (demo_DCL) ; 在螢幕上顯示DCL
-
- 上方此2行 搬移 覆蓋 程式 標示(1)(2)(3) 這三行 即可
-
- (defun c:demo (/ dcl_id funct funct_list)
- (or f:unct (setq f:unct 0))
- (setq funct_list (list "demo 1" "demo 2" "demo 3"))
-
- (setq dcl_id (load_dialog "demo.dcl")) ;原載入dcl ---(1)
- (if (not (new_dialog "demo" dcl_id)) ; ---(2)
- (exit)) ; ---(3)
-
- (start_list "funct")(mapcar 'add_list funct_list)(end_list)
編輯好後另存 demo2.lsp
demo2.lsp - ;***********************************************************************************************
- ;<<<<<< 設定 DCL >>>>>>
-
- (defun demo_DCL ()
- (not (and (setq dcl_file (open (setq tmp (vl-filename-mktemp nil nil ".DCL")) "w"))
- (progn
- (foreach x
- '(
-
- "//"
- "//"
- "//"
- "demo : dialog {"
- " label = "demo2.lsp";"
- " : column {"
- " : boxed_column {"
- " label = "選擇一個功\能";"
- " : popup_list {"
- " key = "funct";"
- " width = 18.0;"
- " fixed_width = true;"
- " alignment = centered;"
- " }"
- " : spacer {"
- " height = 0;"
- " }"
- " }"
- " : button {"
- " label = "&ok";"
- " key = "accept";"
- " width = 18;"
- " fixed_width = true;"
- " alignment = centered;"
- " is_default = true;"
- " } "
- " : button {"
- " label = "&exit";"
- " key = "cancel";"
- " width = 18;"
- " fixed_width = true;"
- " alignment = centered;"
- " is_cancel = true;"
- " }"
- " }"
- " }"
- ) (write-line x dcl_file) )
- (setq dcl_file (close dcl_file))
- (< 0 (setq dcl_id (load_dialog tmp)))
- ) (if (not (new_dialog "demo" dcl_id)) (exit))
- ) ) )
-
- ;***********************************************************************************************
-
-
- (defun c:demo (/ dcl_id funct funct_list)
- (or f:unct (setq f:unct 0))
- (setq funct_list (list "demo 1" "demo 2" "demo 3"))
-
- ;<<<<<< 設定 DCL >>>>>>
-
- (vl-load-com) (demo_DCL) ; 在螢幕上顯示DCL
-
- (start_list "funct")(mapcar 'add_list funct_list)(end_list)
- (if f:unct-def (set_tile "funct" (itoa f:unct-def)))
- (action_tile "accept"
- (strcat
- "(progn (setq f:unct (atoi (get_tile "funct")) f:unct-def f:unct)"
- "(done_dialog)(setq button t))"))
- (action_tile "cancel" "(done_dialog)(setq button nil)")
- (start_dialog)
- (unload_dialog dcl_id)
- (setq funct f:unct)
- (if button
- (cond
- ((= funct 0)(alert "您選擇了範例 1"))
- ((= funct 1)(alert "您選擇了範例 2"))
- ((= funct 2)(alert "您選擇了範例 3"))))
- (princ))
-
這樣就能 一個檔案執行了 demo2.lsp
|