Error Handling Through Batch Process

Error Handling Through Batch Process

ebsoares
Collaborator Collaborator
492 Views
4 Replies
Message 1 of 5

Error Handling Through Batch Process

ebsoares
Collaborator
Collaborator

Hi, all.

 

I have a lisp routine that will always be used while running a batch script on multiple files at a time. One of the process of the routine is to find/open a file through an "if" statement - if it can't find said file, it should provide an error message.

The thing is, I would like to provide an error message like an alert message (that pops up), but it would be really annoying if you are batch processing, say 100 files, and have to press "OK" 100 times (because the batch process we are using does not stop if there's an error with the script/lisp routine, it just keeps trying to move on). Also, a console message would not be ideal, since when we are doing batch processes we don't really pay attention to the console much.

Here's what I was thinking, if said file cannot be found:

  • For the first file in the batch, pop up an error message;
  • Then, after that first one, write up a text error report file (so it knows it provided the first error message)
  • Then not display any error messages after that till the end of the batch process.

Is there a better way to handle this situation? And if so, could someone help me write it up?

 

Thanks in advance,

Edgar

0 Likes
493 Views
4 Replies
Replies (4)
Message 2 of 5

Sea-Haven
Mentor
Mentor

Look into the "A" option in open file it "appends" to a existing file so the 1st step may be create a file say with date then can append, totally untested.

0 Likes
Message 3 of 5

ebsoares
Collaborator
Collaborator

Thanks, @Sea-Haven.

I've been thinking... perhaps I will just use the console alone instead. That way there is no need to create/read extra external files.

Is there a way to hold a message on the console for, say, a full second or second and a half? Since the batch process takes about 10-15 seconds already per file, an extra second won't hurt much. While processing tens of files one would look at the console at least a couple times (I imagine).

0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

The "delay" function does just that stops the clock.

Message 5 of 5

ebsoares
Collaborator
Collaborator

Thanks, @Sea-Haven, I'm almost there. I did a simple test with this code:

 

 

(defun C:test ()
	(princ "\nStarting")
	(command "delay" 5000)
	(princ "\nEnd")
	(princ)
)

 

 

But the command line did the delay first, then the two "princ" lines (out of order then)...

I also found a different way to accomplish the delay without using the "command" function:

 

 

(defun C:test ()
	(princ "\nStarting")
	(wait 5)
	(princ "\nEnd")
	(princ)
)
(defun wait (seconds / stop)
	(setq stop (+ (getvar "DATE") (/ seconds 86400.0)))
	(while (> stop (getvar "DATE")))
)

 

 

Bu the result was exactly the same. Here's what appeared on the command line:

Command: TEST <<this line was delayed for 5 seconds. Really, just "Command: TEST" for 5 seconds>>
Starting
End
Command:

 

Do you see what I am doing wrong? I would like to have "Starting" delayed in the command line for 5 (or however many) seconds...

Thanks in advance!

0 Likes