Joe-Bouza 发表于 2022-7-6 05:25:03

Lisp新手:格式错误的参数

你好
我正在完成我在Afralisp的第一个教程,我不断得到错误错误的论点。我知道我做错了什么,但我想不出来。我甚至粘贴了代码以确保没有拼写错误。我将lisp文件保存在搜索路径的support文件夹中,但当我尝试(加载“testline”)时,它不起作用。我哪里出错了?
 

(defun testline ()
   ;define the function

   (setq a (getpoint "\nEnter First Point : "))
   ;get the first point   (setq b (getpoint "\nEnter Second Point : "))    ;get the second point

   (command "Line" a b "")
   ;draw the line

)    ;end defun

Tharwat 发表于 2022-7-6 05:40:32

这样试试。。。
 

(defun c:testline (/ a b)
                                       ;define the function
(if (and (setq a (getpoint "\nEnter First Point : "))
                                       ;get the first point
          (setq b (getpoint "\nEnter Second Point : "))
                                       ;get the second point
   )
   (command "_.Line" "_none" a "_none" b "")
                                       ;draw the line
)                                     ;end defun
)

SLW210 发表于 2022-7-6 06:01:04

请阅读代码发布指南并编辑您的帖子,将代码包含在代码标签中。

jdiala 发表于 2022-7-6 06:02:40

 
(defun C:testline (/ a b) ;; add C: to execute the command testline
;; (/ a b) localize your variables
;define the function

(setq a (getpoint "\nEnter First Point : "))
;get the first point ; everything after the semi colon will be treated as a comment and will not be evaluated
;; move (setq b on the next line
(setq b (getpoint "\nEnter Second Point : "))        ;get the second point

(command "_.Line" "_none" a "_none" b "")
;; underscore means to use the english equivalent of the command
;; use . or period just in case the command in use has been undefined
;; _none is a transparent command setting the snapmode to 0. If you didn't use _none or _non. If variable point a or b is close to an object either or both will snap to that object.

;draw the line
(princ) ;; exit quietly

)        ;end defun

Joe-Bouza 发表于 2022-7-6 06:18:19

谢谢大家
我找到了丢失的括号:震惊:

Tharwat 发表于 2022-7-6 06:33:54

........
页: [1]
查看完整版本: Lisp新手:格式错误的参数