Author Topic: Is there a way to detect if a script is running?  (Read 1851 times)

0 Members and 1 Guest are viewing this topic.

terrycadd

  • Guest
Is there a way to detect if a script is running?
« on: December 15, 2006, 01:51:34 AM »
Is there a way to detect if a script is running during the loading of S::Startup in AcadDoc.lsp?  We have several functions that we run slightly different, if a script has executed them, by including the line (setq *script* t) as the first line after it opens a drawing and before it executes a function such as our (PlotRoutine).  The “PlotRoutine” checks if the *script* variable is true and it then reads a file on the users local drive to use as the plot settings; else it uses the variables in memory to plot the layouts.  This concept works great for all folder related scripts.

This week I was asked to find a way to not run certain S::Startup functions if a script is running.  The list of functions to exclude are company specific and slow down the script process.  In the S::Startup function I tested for *script*.  It always returns nil.  So the script commands are not executed until after AcadDoc.lsp is loaded.  I’m thinking about having the script file create a temp file, and then have it delete it at the end of the script.  I can then check for the temp file, instead of if the variable *script* is true.
Is there a better way using VBA that can detect if a script is running or an alternative method that will work better?
« Last Edit: December 15, 2006, 01:55:19 AM by Terry Cadd »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Is there a way to detect if a script is running?
« Reply #1 on: December 15, 2006, 02:04:33 AM »
Have you had a look at the CMDACTIVE System Variable ?
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.

terrycadd

  • Guest
Re: Is there a way to detect if a script is running?
« Reply #2 on: December 15, 2006, 04:33:04 PM »
You're right. I always thought about "CMDACTIVE" as relating to a regular command. I wasn't able to research this until this afternoon, but here is the info in Acad help.
Thanks,
Terry

1 Ordinary command is active
2 Ordinary command and a transparent command are active
4 Script is active
8 Dialog box is active
16 DDE is active
32 AutoLISP is active (only visible to an ObjectARX-defined command)
64 ObjectARX command is active