Pass lisp variable to batch file that requires arguments

Pass lisp variable to batch file that requires arguments

Anonymous
Not applicable
756 Views
3 Replies
Message 1 of 4

Pass lisp variable to batch file that requires arguments

Anonymous
Not applicable

I have a batch file i am calling from a lisp. It requires an argument that I want to pass from the lisp. How do I do this? I'm using the (startapp "filename.ext") function to call the batch file from a lisp.

0 Likes
757 Views
3 Replies
Replies (3)
Message 2 of 4

TheCADnoob
Mentor
Mentor
0 Likes
Message 3 of 4

Paul_Gander
Advocate
Advocate

 

@Anonymous

 

You could add some code to your lisp routine that will write a new temporary batch file containing a call to the main batch file with the arguments you want and then execute the temporary batch file using AutoCAD's SHELL command.

 

You did not specify the name of your batch file or the nature of the arguments you wanted to pass to it so here is a generic example with 2 arguments stored in variables:

 

(setq file_id (open "c:\\your path\\your temp batch.bat" "w"))
(write-line (strcat "\"c:\\your path\\your batch.bat\" " your_first_argument_string " " your_next_argument_string) file_id)
(close file_id)
(command "shell" "\"c:\\your path\\your temp batch.bat\"")

 

0 Likes
Message 4 of 4

Anonymous
Not applicable
Thank you.  I will try to test soon. 
0 Likes