Jump to content

Recommended Posts

Posted (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 by maahee

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...