<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run multiple lisp with one command. in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13084279#M7957</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15935905"&gt;@DOODLEANU&lt;/a&gt;&amp;nbsp;You can do this with vl-catch-all-apply function. Here is function that you can pass multiple functions too and catch their errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun attemptFunctions (function-list / errorList i)
	(foreach func function-list
		(if (vl-catch-all-error-p (vl-catch-all-apply (quote (eval func)) nil))
			(setq errorList (cons 1 errorList))
			(setq errorList (cons nil errorList))
			
		)
	)
	(setq i 0)
	(foreach err (reverse errorList)
		(if err
			(progn 
				(princ "\nFunction " )
				(princ (nth i function-list))
				(princ " failed to complete successfully!\n")
			)
		)
		(setq i (+ i 1))
	)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a test procedure to see how it could work for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:t1 ()
	(print "Test 1")
)

(defun c:t2 ()
	(print "Test 2")
	(itoa p)
)

(defun c:t3 ()
	(print (strcat "Hi" 3))
)
(defun c:testall ()
	(attemptFunctions '(c:t1 c:t2 c:t3))
	(print "Done")
	(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you run the "testall" function, you should get the following results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;"Test 1"
"Test 2"
Function C:T2 failed to complete successfully!
Function C:T3 failed to complete successfully!
"Done"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Oct 2024 22:31:24 GMT</pubDate>
    <dc:creator>MrJSmith</dc:creator>
    <dc:date>2024-10-14T22:31:24Z</dc:date>
    <item>
      <title>Run multiple lisp with one command.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13082509#M7954</link>
      <description>&lt;P&gt;I have three Lisp programs:&lt;/P&gt;&lt;P&gt;By Entering a cmd a single cmd "ALL3"&lt;/P&gt;&lt;P&gt;I want to run all these programs sequentially.&amp;nbsp;&lt;/P&gt;&lt;P&gt;C : Foo&lt;/P&gt;&lt;P&gt;C : wow&lt;/P&gt;&lt;P&gt;C : QPR&lt;/P&gt;&lt;P&gt;If any error occurs during execution, it should skip the current program and move on to the next one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all programs complete successfully, display the message: "Routine successful."&lt;/P&gt;&lt;P&gt;If some programs are skipped due to errors, display the message: "Completed with errors."&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 06:46:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13082509#M7954</guid>
      <dc:creator>DOODLEANU</dc:creator>
      <dc:date>2024-10-14T06:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple lisp with one command.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13082783#M7955</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15935905"&gt;@DOODLEANU&lt;/a&gt;&amp;nbsp; hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in order to do this, each program (e.g the last running function) must be well designed and return a value for it's success or fail otherwise the next program will not run.&amp;nbsp;it is programmer responsibility to do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if we do not know what is:&lt;/P&gt;&lt;P&gt;(C:Foo)&lt;/P&gt;&lt;P&gt;(C:wow)&lt;/P&gt;&lt;P&gt;(C:QPR)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can we help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;post an example of these 3 programs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Moshe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 09:25:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13082783#M7955</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2024-10-14T09:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple lisp with one command.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13083821#M7956</link>
      <description>&lt;P&gt;When running a Lisp, Acad does so in a data space session (single space to do it's thing).&lt;/P&gt;&lt;P&gt;When an error occurs, it ends the session and gives you an error message of some kind.&lt;/P&gt;&lt;P&gt;So, if you have a single session that calls other loaded functions, when any one fails,&lt;/P&gt;&lt;P&gt;it stops. You can trap that error, if you have *error* set to some local error handler.&lt;/P&gt;&lt;P&gt;But, it (will not) just 'skip' it, and resume the calling program.&lt;/P&gt;&lt;P&gt;You could find out if all ran with something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun C:ALL3 ()
(defun C:CheckALL3 ()
 (if (= Flag 1)(alert "Routine successful."))
); function CheckALL3
;; Run all 3 programs
 (setq Flag nil)
 (C:Foo)
 (C:wow)
 (C:QPR)
 (setq Flag 1)
 (C:CheckALL3)
); function ALL3&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it will (not) just continue with an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could also do a script with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;(C:Foo)&lt;BR /&gt;(C:wow)&lt;BR /&gt;(C:QPR)&lt;/P&gt;&lt;P&gt;And in each called program, put in an error trap with (command "_resume")&lt;/P&gt;&lt;P&gt;as an experiment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ECCAD&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 18:35:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13083821#M7956</guid>
      <dc:creator>ec-cad</dc:creator>
      <dc:date>2024-10-14T18:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple lisp with one command.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13084279#M7957</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15935905"&gt;@DOODLEANU&lt;/a&gt;&amp;nbsp;You can do this with vl-catch-all-apply function. Here is function that you can pass multiple functions too and catch their errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun attemptFunctions (function-list / errorList i)
	(foreach func function-list
		(if (vl-catch-all-error-p (vl-catch-all-apply (quote (eval func)) nil))
			(setq errorList (cons 1 errorList))
			(setq errorList (cons nil errorList))
			
		)
	)
	(setq i 0)
	(foreach err (reverse errorList)
		(if err
			(progn 
				(princ "\nFunction " )
				(princ (nth i function-list))
				(princ " failed to complete successfully!\n")
			)
		)
		(setq i (+ i 1))
	)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a test procedure to see how it could work for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:t1 ()
	(print "Test 1")
)

(defun c:t2 ()
	(print "Test 2")
	(itoa p)
)

(defun c:t3 ()
	(print (strcat "Hi" 3))
)
(defun c:testall ()
	(attemptFunctions '(c:t1 c:t2 c:t3))
	(print "Done")
	(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you run the "testall" function, you should get the following results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;"Test 1"
"Test 2"
Function C:T2 failed to complete successfully!
Function C:T3 failed to complete successfully!
"Done"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 22:31:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-multiple-lisp-with-one-command/m-p/13084279#M7957</guid>
      <dc:creator>MrJSmith</dc:creator>
      <dc:date>2024-10-14T22:31:24Z</dc:date>
    </item>
  </channel>
</rss>

