Author Topic: "find in files"  (Read 8665 times)

donmadden

  • Community Member
  • Posts: 6
  • Hero Points: 0
"find in files"
« on: August 01, 2007, 12:26:02 PM »
Hi,

I am using SlickEdit Version 11.02. I am using the "definit" within my own custom macro with arg(1)!=L to detect when the user has invoked the editor. Using that I intend to display the splash screen every time the user opens the slick edit editor. This is shown below in red.

It manages to show the splash screen. Unfortunately when I invoke the operation "Find In Files" and hit OK, it also has the effect of calling definit() with arg(1)!=L resulting in the splash screen being displayed.

Anyone any ideas please on why the "Find In Files" operation has this effect and if it is easy to prevent? No other slick edit operations seem to have this effect? If not, any other suggestions on when I can show a splash screen every time the user invokes slick edit.

Thanks,
Don

definit()
{
 if (arg(1)!="L") {
   form_wid=show('StartUpSplashScreen');
   delay(200,"K");     
   form_wid._delete_window();   
   }

}

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 798
  • Hero Points: 54
Re: "find in files"
« Reply #1 on: August 03, 2007, 09:02:19 PM »
Try this:


// Global variable set in main.e AFTER all definit()s have run
_str _editor_cmdline;

static void MaybeStartupSplashScreen()
{
   // Only show splash if the the -mdihide switch was not passed to this instance of the application
   if( 0 == pos("-mdihide",_editor_cmdline,1,'i') ) {
      form_wid=show('StartUpSplashScreen');
      delay(200,"K");     
      form_wid._delete_window();
   }
}

definit()
{
   if( arg(1) != 'L' ) {
      _post_call(MaybeStartupSplashScreen);
   }
}


The problem is that invoking a multi-file find will spawn a hidden instance of vs.exe and pipe the results back to the visible instance for display in the Search Results tool window. Your definit() needs to know when it was invoked from a hidden instance.

--rodney

donmadden

  • Community Member
  • Posts: 6
  • Hero Points: 0
Re: "find in files"
« Reply #2 on: August 07, 2007, 01:32:16 PM »
Hi Rodney,

Thanks very much for providing the reason as to why the "find in files" invokes 'definit()' (i.e, due to a spawned instance of vs.exe). Thanks also for providing the solution below which works, especially showing the need for '_post_call()'.

As a matter of interest, why is the ' _post_call(MaybeStartupSplashScreen)' required instead of just directly calling ' 'MaybeStartupSplashScreen()'?

Thanks again for your helpful solution.

Cheers
Don

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 798
  • Hero Points: 54
Re: "find in files"
« Reply #3 on: August 07, 2007, 01:39:33 PM »
Whatever you call in _post_call() gets run after the current macro(s). Since _editor_cmdline is set after all the definit()'s are called (in main.e), it was necessary to _post_call() MaybeStartupSplashScreen(). definit()s are always called before anything else, including the bootstrap main.e module.

--rodney

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: "find in files"
« Reply #4 on: June 27, 2008, 05:18:51 AM »
This topic just helped me solve a very similar problem I had -- same exact scenario except that I'm setting a timer instead of showing a splash screen.  I had already deferred setting the timer using _post_call, but it gave a Slick-C stack every time I tried to find in files ("Invalid HVAR argument" and the line in question is simply if (myGlobalVar >= 0)).

I don't understand why myGlobalVar is an invalid HVAR only in the background vs.exe process, but the -mdihide trick below lets me avoid running my code in that scenario, and resolved the symptom.

Thanks almost a year later, Rodney!  The topic was easy to find just by searching for "definit" and saved me who knows how many hours of troubleshooting.  :)  HP++ of course.