PDA

View Full Version : IF function



Vismut65
17th Apr 2012, 07:54 am
Hi,

I have made an IF function. But it doesn't work. The code is below.

If the value of "l_kyl" is larger or smaller than "7" I want two different blocks to be inserted. It only takes the first block independent of the value of "l_kyl". Someone who knows and can help me?.
/Dan



(if (= feet "1")
(progn
(if (< l_kyl "7") (command "_.insert" "P:\\CAD\\r18G\\Drives\\DUE\\Dimritning\\L3\\Fot\\L 3_fot_H_W.dwg" "0,0" "1" "1" "0"))
(if (> l_kyl "7") (command "_.insert" "P:\\CAD\\r18G\\Drives\\DUE\\Dimritning\\L3\\Fot\\L 3_fot_H_A.dwg" "0,0" "1" "1" "0"))
))

MSasu
17th Apr 2012, 08:01 am
Try to make the comparison using numbers instead:

(< (atof l_kyl) 7)

Tharwat
17th Apr 2012, 08:04 am
Use cond function instead of if function .

Vismut65
17th Apr 2012, 08:05 am
Thank you MSasu very much it works.:D

/Dan

MSasu
17th Apr 2012, 08:07 am
Use cond function instead of if function .
Since there are only two cases for l_kyl variable, then IF statement is an apropriate solution.
However, I will format the code like:

(setq pathBlock "P:\\CAD\\r18G\\Drives\\DUE\\Dimritning\\L3\\Fot\\")
(if (= feet "1")
(if (< (atof l_kyl) 7)
(setq nameBlock "L3_fot_H_W.dwg")
(setq nameBlock "L3_fot_H_A.dwg")
)
)
(command "_.INSERT" (strcat pathBlock nameBlock) '(0.0 0.0) "1" "1" "0")