Lisp not working as desired - Help is appreciated.

Lisp not working as desired - Help is appreciated.

vporrash141089
Advocate Advocate
367 Views
4 Replies
Message 1 of 5

Lisp not working as desired - Help is appreciated.

vporrash141089
Advocate
Advocate

Hi guys, I've started a Lisp tutorial and wanted to work on a function to repeat with user input, as many times as the user wants, can someone please help?

 

Thanks in advance and here is the code

 

(defun c:RPA (/)

(setq n (repeat (getint "\n Enter times to purge and audit")))

(if (> 0 n)

(progn

(command "-Purge" "r" "*" "n" "-Purge" "a" "*" "n" "Audit" "y")
(princ "\nThis file has been Purged and Audited succesfully!!")
)
)

(princ)
)

0 Likes
Accepted solutions (1)
368 Views
4 Replies
Replies (4)
Message 2 of 5

paullimapa
Mentor
Mentor
Accepted solution

try switching it around like this and see if this works (not tested):

 

(defun c:RPA (/)
(setq n (getint "\n Enter times to purge and audit"))
(if (> n 0)
 (progn
  (repeat n
   (command "-Purge" "r" "*" "n" "-Purge" "a" "*" "n" "Audit" "y")

  )
  (princ "\nThis file has been Purged and Audited succesfully!!")
 ) ; progn
) ; if
(princ)
) ; defun


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 5

vporrash141089
Advocate
Advocate

Thank you so much! 

0 Likes
Message 4 of 5

paullimapa
Mentor
Mentor
Glad to have helped cheers

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 5

Sea-Haven
Mentor
Mentor

Just a suggestion using purge around 3 times is normally enough. So maybe hard code a (repeat 3 or more, doing a purge multiple times does not hurt even if nothing is found. How many times have you repeated purge  as a maximum ? Note if using CIV3D need Purgestyles, took 3 goes to remove CIV3D styles. Civ3D locks numerous stuff if named in styles.

0 Likes