Search the Community
Showing results for tags 'while function'.
-
hi frids, if there is any other way to do this program in simply..please help me plpl.csv
-
Hi all, I'm stuck inside the while loop and can't come out of it. Can someone help me on this (if possible please provide information on why its not closing). This is just a small function of a much larger lisp that I'm playing with and Esc to exit means complete program termination. Here is how I inteded it to be used for. Once user decides to use drawshapes, and if the answer is one of the keyword (eg. Rectangle) then user should be able draw as many rectangles he likes and if Enter is hit it should come back to main menu again ask for keyword to choose (circle or ellipse). Thanks in advance. (defun drawshapes (/ dtype) (setvar "cmdecho" 1) (setq dtype T) (while dtype (initget (+ 2 4) "R P C E") (prompt "\n*** Enter option R, P, C, E ***") (setq dtype (getkword "\nselect your option: Rectangle, Pline, Circle, Ellipse or hit Enter to close:")) (if dtype (cond ( (= dtype "R") (setq loop T) (while loop (command "_.rectang") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "P") (setq loop T) (while loop (command "_.PLINE") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "C") (setq loop T) (while loop (command "_.circle") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ( (= dtype "E") (setq loop T) (while loop (command "Ellipse") (while (= 1 (logand 1 (getvar 'CMDACTIVE)))(command pause)) ); end while ) ); end cond ); end if ); end while (setvar "cmdecho" 0) );end defun
- 14 replies
-
Feedback On Code That allows only 5 digit interger input.
Reu posted a topic in AutoLISP, Visual LISP & DCL
Just experimenting with the 'while' function and looking for feedback as to the quality of my coding. (defun c:test (/) (setq count 0) (setq 5dig (getint "\nEnter a 5 digit number: ")) ;_Enter a 5 digit number. (while (/= count 5) (setq 5dig (getint "\nTry again, please enter a 5 digit number: ")) (setq strcount (itoa 5dig)) ;_Set a variable "strcount" to string from the interger from the variable "5dig" (setq count (strlen strcount) ;_Count the length of characters in the variable "strcount" ) ) (princ "\nYour are the Winner!") (princ) ) Thanks