Code Red > AutoLISP (Vanilla / Visual)

Running External Programs

(1/3) > >>

cmwade77:
I am currently using StartApp to launch an external program; however, I need to wait for that external program to finish its job before my LISP routine continues. I know it would be possible to use DOSLib to do this; however, I would like to avoid dependence on a third party if I can, does anyone have some ideas?

I could potentially loop until a file is created; however, there is the very real possibility that the file won't get created all of the time and would end up in an endless loop, so I would like something with a bit more of a failsafe.

framednlv:
What happens if you use Start?

MP:
Use an instance of shell with the wait flag set to true (-1).
Bonus, set the visibility flag to 0 if you to hide execution.
The external program may override the latter.

e.g.

(progn
    (setq shell (vlax-create-object "WScript.Shell"))
    (vl-catch-all-apply 'vlax-invoke (list shell 'run "cmd.exe" 8 -1)))
    (alert "lol, there you are.")
    (vl-catch-all-apply 'vlax-release-object (list shell))
    (princ)
)

cmwade77:

--- Quote from: framednlv on October 21, 2020, 07:43:16 PM ---What happens if you use Start?

--- End quote ---
I tried that and it kept launching another session of AutoCAD, no idea why.

cmwade77:

--- Quote from: MP on October 21, 2020, 08:07:17 PM ---Use an instance of shell with the wait flag set to true (-1).
Bonus, set the visibility flag to 0 if you to hide execution.
The external program may override the latter.

e.g.

(progn
    (setq shell (vlax-create-object "WScript.Shell"))
    (vl-catch-all-apply 'vlax-invoke (list shell 'run "cmd.exe" 8 -1)))
    (alert "lol, there you are.")
    (vl-catch-all-apply 'vlax-release-object (list shell))
    (princ)
)

--- End quote ---

Thank you, that did the trick, I am actively getting there on my routine, I am quite surprised at how well this is working. I will eventually share the whole package, but there are a lot of pieces to it.

Navigation

[0] Message Index

[#] Next page

Go to full version