Enter key to repeat

Enter key to repeat

saitoib
Advocate Advocate
2,701 Views
21 Replies
Message 1 of 22

Enter key to repeat

saitoib
Advocate
Advocate

Hi all!

I want to make it so that when I ask for user input in a while iteration, if the value is the same as the last time, all I have to do is press Enter.
So, I came up with the following code.
However, I'm wondering if I can make it a bit smarter and more Lisp-like.

 

Please give me some advice.

(defun c:test1 (/ inp temp)
	(while (and
		(if (not inp)
			(progn
				(initget 7)
				(setq inp (getreal "\nEnter a real number :"))
			)
			(progn
				(initget 6)
				(setq temp inp)
				(prompt "\nEnter a real number <")
				(princ inp)
				(setq inp (getreal "> :"))
				(if (not inp)
					(setq inp temp)
					(setq inp inp)
				)
			)
		)
		(princ "\nInput Data = ")
		(princ inp)
		(princ)
	))
)

 

Saitoib
0 Likes
Accepted solutions (3)
2,702 Views
21 Replies
Replies (21)
Message 21 of 22

Sea-Haven
Mentor
Mentor

Your correct saved on the pc in the registery.

0 Likes
Message 22 of 22

john.uhden
Mentor
Mentor

@Kent1Cooper 

As civils, we are often creating the building footprint from architect's plans, so we like to enter the distances in architectural format, verbatim.  I have also learned not to trust the PDF they send you in terms of tracing their linework.  So the published distances are gospel, as they would be to the builder.

John F. Uhden

0 Likes