(= A nil) and at same time (= B nil) ... stop the while XX

(= A nil) and at same time (= B nil) ... stop the while XX

Anonymous
Not applicable
1,798 Views
26 Replies
Message 1 of 27

(= A nil) and at same time (= B nil) ... stop the while XX

Anonymous
Not applicable

Good afternoon everybody.
I have a routine that writes the value of getpoin "A" and getpoint "B", and now I need it when (= A nil) and at the same time (= B nil), the routine leaves the cycle and stops.
someone tell me how do i stop when two entrances (getpoint) are invalid, o (while xx, stop?

 

Thanks

 

0 Likes
Accepted solutions (2)
1,799 Views
26 Replies
Replies (26)
Message 21 of 27

ВeekeeCZ
Consultant
Consultant

Ohh boy, just a quick glance scared you to give up. There is really nothing complicated - there is no lambda! Take some time to have a deeper look, make notes, I'll try to explain.

 

0 Likes
Message 22 of 27

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

I really appreciate the help, after modifying the routine, it works well in that aspect of skipping the first input if there is no valid value and the second, all right ...
now I just need it, and I just saw it now, what I need is the part of:

 

(setq aa (atof (rtos y1 2 p)))
(setq aa1 (atof (rtos y2 2 p)))
(if (> aa 0) (progn (setq yy (strcat "+" (rtos y1 2 p) "(NA)")))) ; why progn?? (4 times bellow too)
(if (< aa 0) (progn (setq yy (strcat (rtos y1 2 p) "(NA)")))) ; missing space
(if (> aa1 0) (progn (setq yy1 (strcat "+" (rtos y2 2 p) "(NO)"))))
(if (< aa1 0) (progn (setq yy1 (strcat (rtos y2 2 p) "(NO)")))) ; again

 

If i use (if ...) gives an error.

 


 

0 Likes
Message 23 of 27

ВeekeeCZ
Consultant
Consultant

I've tried to add some comments to help you to understand. HTH

 

0 Likes
Message 24 of 27

Anonymous
Not applicable

ok, thank you very much

0 Likes
Message 25 of 27

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

I really appreciate the help, after modifying the routine, it works well in that aspect of skipping the first input if there is no valid value and the second, all right ...
now I just need it, and I just saw it now, what I need is the part of:


(defun C:CT_5 ( / sc p r pt1 pt2 y1 yy)
  
(setvar "cmdecho" 0)
(setvar "DIMZIN" 0)  

(setvar "ATTREQ" 1)
(setvar "ATTDIA" 0)
  
(COMMAND "LAYER"	 "m"	       "A-00-COTA_NIV" "T"
	   "A-00-COTA_NIV" "S"	       "A-00-COTA_NIV" ""
	  )
  (setq sc (getreal "\nscala ?  "))
  (setq P (getint  "\ndecimal ?  "))
  (setq a "T")
  (setq r 0)		

(while 
    (progn
	(and
	  (setq pt1 (getpoint "\npoint (NA) ? : "))
	  	;;(setq aa (atof (rtos y1 2 p)))		;<-- y1 does not exist yet hence the error
		(setq y1 (cadr pt1))				;<- this will happen only if pt1 is valid
	  	(setq yy (strcat (if (minusp y1) "" "+")	;<--at this point you can assign the value to yy
			       (rtos y1 2 P)  " (NA)"))
	  )
	(and (setq pt2 (getpoint "\npoint (NO) ? : "))
		;;(setq aa1 (atof (rtos y2 2 p)))		;<-- y2 does not exist yet hence the error
	     	(setq y2 (cadr pt2))				;<- this will happen only if pt2 is valid
	     	(setq yy1 (strcat (if (minusp y2) "" "+")	;<--at this point you can assign the value to yy1
			       (rtos y2 2 P)  " (NO)"))
	     )       	      	
	(or pt1 pt2)
    )
	(cond
	  ((and pt1 pt2)	)
	  ( pt1 (setq yy1 " ")	)
	  ( pt2 (setq yy " " pt1 pt2)	)
	  )
  
  (command "insert" "nivel_corte_na+no" pt1 sc "" r yy yy1)
  )
 (command "insert" "nivel_corte_na+no" pause sc "" r "" "")  
  (princ)
  )

minusp < -- Verifies that a number is negative | equivalent to your test of (< aa 0) and (< aa1 0)

 

HTH

 

0 Likes
Message 26 of 27

Anonymous
Not applicable

thank you very much, now I really managed to get the routine to work as I wanted.
Thanks a lot for the help.

0 Likes
Message 27 of 27

pbejse
Mentor
Mentor

@Anonymous wrote:

thank you very much, now I really managed to get the routine to work as I wanted.
Thanks a lot for the help.


You are welcome, but more importantly, you should learn from it. 

Keep practicing @Anonymous , you will get good at it in no time.

 

 

0 Likes