Author Topic: Run a command as if from the command line  (Read 2233 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 362
Run a command as if from the command line
« on: January 03, 2014, 08:49:29 PM »
I'm working on a routine that needs to run the MIRROR command in the middle of a lisp function.  Rather than simulating all the calls and data gathering then using (command "mirror" .... ) where I pass in the the previously gathered data I'd like to find a way to have my routine call the mirror function and let it run as a command line function (prompting for input, etc.), then returning control to my lisp function.  Is there a way to do this?
"Science is the belief in the ignorance of experts." - Richard Feynman

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Run a command as if from the command line
« Reply #1 on: January 03, 2014, 09:16:06 PM »

Try something like :
Code - Auto/Visual Lisp: [Select]
  1. (defun c:doit ()
  2.   (apply 'vl-cmdf (list "_.MIRROR"))
  3.   (while (> (getvar "cmdactive") 0) (vl-cmdf pause))
  4.  
  5.   (setq success (getstring t "Say What"))
  6.   (alert (strcat "We got to here\n" success))
  7.   (princ)
  8. )


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

hmspe

  • Bull Frog
  • Posts: 362
Re: Run a command as if from the command line
« Reply #2 on: January 03, 2014, 10:42:50 PM »
Thanks.
"Science is the belief in the ignorance of experts." - Richard Feynman

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Run a command as if from the command line
« Reply #3 on: January 03, 2014, 11:40:43 PM »
de nada
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Run a command as if from the command line
« Reply #4 on: January 04, 2014, 12:04:02 PM »
A minor point, but:
Code - Auto/Visual Lisp: [Select]
  1. (apply 'vl-cmdf (list "_.MIRROR"))

Could just be:
Code - Auto/Visual Lisp: [Select]
  1. (vl-cmdf "_.mirror")

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Run a command as if from the command line
« Reply #5 on: January 04, 2014, 02:01:54 PM »
You may also want set CMDECHO to 1.  Otherwise you could be flying blind   :wink:
R12 Dos - A2K

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Run a command as if from the command line
« Reply #6 on: January 04, 2014, 05:34:25 PM »
A minor point, but:
Code - Auto/Visual Lisp: [Select]
  1. (apply 'vl-cmdf (list "_.MIRROR"))

Could just be:
Code - Auto/Visual Lisp: [Select]
  1. (vl-cmdf "_.mirror")

I'm in the habit of doing it my way because I often pass arguments in the list.
Sort of comes second nature to set up for the extended functionality.
//=================

You may also want set CMDECHO to 1.  Otherwise you could be flying blind   :wink:

yes :)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Run a command as if from the command line
« Reply #7 on: January 04, 2014, 06:48:01 PM »
A minor point, but:
Code - Auto/Visual Lisp: [Select]
  1. (apply 'vl-cmdf (list "_.MIRROR"))

Could just be:
Code - Auto/Visual Lisp: [Select]
  1. (vl-cmdf "_.mirror")

I'm in the habit of doing it my way because I often pass arguments in the list.
Sort of comes second nature to set up for the extended functionality.

I'm not sure I follow - surely arguments could still be passed using the single vl-cmdf statement?
Code - Auto/Visual Lisp: [Select]
  1. (vl-cmdf "_.mirror" arg1 arg2 ... argN)