maahee Posted Monday at 08:19 AM Posted Monday at 08:19 AM (edited) (defun c:Stair () (setq ftn 2) (setq rsn 24) (setq counter 1) ; Initialize a counter for the flight steps (while (> ftn 0) ; Loop until ftn is no longer greater than 0 ; (setq step-prompt ) ; Dynamic prompt based on counter (setq fstfn (getint (strcat "\n" (rtos counter 2 0) " flight steps (max 15, remaining " (rtos rsn 2 0) "): "))) ; Prompt for user input (while (or (> fstfn 15) (> fstfn rsn)) ; Check if input exceeds max step or remaining steps (if (> fstfn 15) (princ "\nPlease enter a step count within 15: ") ) (if (> fstfn rsn) (princ (strcat "\nPlease enter a step count within remaining steps of " (rtos rsn 2 0) ": ")) ) (setq fstfn (getint (strcat "\n" (rtos counter 2 0) " flight steps (max 15, remaining " (rtos rsn 2 0) "): "))) ) (setq counter (+ counter 1)) ; Increment counter by 1 (setq ftn (- ftn 1)) ; Decrement ftn (setq rsn (- rsn fstfn)) ; Decrement ftn ; Store the input value in the list ) ) it is part of the code (if (> fstfn rsn) (princ (strcat "\nPlease enter a step count within remaining steps of " (rtos rsn 2 0) ": ")) ) ; In the second condition, the number of risers "(setq rsn 24)" should be equal to the total sum of all riser input by user "(setq fstfn (getting))" . automatically calculate the remaining riser for the last flight and input it in the line "(setq fstfn (getint (strcat "\n" (rtos counter 2 0) " flight steps (max 15, remaining " (rtos rsn 2 0) "): ")))" example 1. first flight step 10 (user input ) then second flight step 14, 2. if flight more than 2 then first flight step 10 (user input ) second flight step 10 (user input ) third flight step 4 3. 1 flight steps (max 15, remaining 24): display like this first flight steps (max 15, remaining 24): one line code or shortest code 4. undo function if user enters wrong input for re-enter two step back Edited Monday at 08:22 AM by maahee Quote
SLW210 Posted Monday at 01:19 PM Posted Monday at 01:19 PM I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. Please post in the correct forum. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.