Auto Lisp 快速上手 - 004

  • Share this:

Setq Command (Set Equal 多瞄一下 英文 的全文 , 可助記憶指令 , 這是此系列有較多原文的原因 )

(Setq) 是一個指派指令 , 如 : 指定一個變數或常數的值給另一個變數 .

NOTE : (Setq) 在 AutoLisp 當中是一個主要的指派指令 . “ = ” 不被用來指定變數 . “ = ” 這個指令是存在的 , 但不用在指派變數的陳述 . 它沒有能力指定一個變數等於另外一個變數 . ( 它是用來比較變數 , 數值或字串是否相同的 )

(setq a b)

設定 b 的值 為變數 a 的值 .

NOTE : 在 (setq 後面的第一個變數是要設定的變數名稱 , 上例為 a .

Print Commands 列印指令

Prompt 提示 此指令用在指令行 , 列印簡單的訊息 . 跳行控制碼 (n) 是不被包含在裡面的 , 兩個連續不斷的提示 ( prompt ) 指令的訊息會被列印在同一行 . 所以 , 任何在 prompt 之後的列印 , 必須加上 (terpri) 或 n .

(terpri)

此為跳行指令 ( line feed ) 控制後面要列印的文字列印在下一行 . 一般跟隨在 prompt 指令之後 . 如 :

(prompt "Hello, how are you ?")(terpri)

(prompt "nHello, how are you ?")

Prin1

將表示式列印於命令區或已開啟的檔案 , 控制碼字元則以 "" 為字首展開 .

(prin1 "Hello") 列印 Hello

(prin1 a) 列印變數 a 的值

(prin1 a f) would print the value of variable a to an open file named in variable f

Princ

除控制碼字元則不以 "" 為字首展開外其餘同 prin1 . 也可以在 princ 後面不輸入任何表示式 , 而只列印一行空白行 .

Print

除表示式會往下一新行列出 , 及一空格外其餘同 prin1 .

(print "Hello") would return "Hello" "Hello"


Tags: