Author Topic: Invoke a macro when changing the active project configuration  (Read 6483 times)

LongSteve

  • Community Member
  • Posts: 11
  • Hero Points: 1
Invoke a macro when changing the active project configuration
« on: September 14, 2009, 05:14:06 PM »
Hi all,

I've done a bit of searching and can't seem to find what I'm looking for.  I would like to invoke a few actions when I change the active configuration for a project I have.  Or alternatively, is it possible to change the current active project configuration from a macro?

Can anyone point me in the general direction for doing this? 

Thanks very much,

Steve

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Invoke a macro when changing the active project configuration
« Reply #1 on: September 14, 2009, 09:19:17 PM »
What version of slickedit and what O.S.?

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Invoke a macro when changing the active project configuration
« Reply #2 on: September 14, 2009, 11:54:48 PM »
I'm using the SE callback mechanism to trigger/hook on project (config) changes e.g. to apply some special project build settings and such.
Example:
Code: [Select]
void _prjconfig_hs2()
{
   // hook for special project setup: check project path containing '\project\requiring\special\setup'
   // say ("_prjconfig_hs2: _project_name=" _project_name " PROJECT=" get_env( 'PROJECT'));
   if ( (get_env( 'PROJECT') :!= "") && pos( '\project\requiring\special\setup', _project_name ) ) rbuildprj();
}

void _prjopen_hs2 ()
{
   // also needed on startup
   // say ("_prjopen_hs2: _project_name=" _project_name " PROJECT=" get_env( 'PROJECT'));
   _prjconfig_hs2();
}

// special project setup fct.
_command int rbuildprj ( )
{
   exit_process ();
   clear_pbuffer ();

   ... whatever needed ...

}

In addition I'm using this little cmdline helper to quickly change the current project (build) config [Release/Debug]:
Code: [Select]
_command void qprojcfg ( _str config ='' ) name_info (','VSARG2_MARK|VSARG2_TEXT_BOX|VSARG2_READ_ONLY)
{
   if ( config == '' )
   {
      get_string ( config, '[R-elease,D-ebug]: ', NONE_ARG, gActiveConfigName );
   }

   if( pos( '^R', config, 1, 'ri' ) ) config = 'Release';
   else if ( pos( '^D', config, 1, 'ri' ) ) config = 'Debug';
   else
   {
      message ("current config: " gActiveConfigName " [configs: release,debug]");
      return;
   }

   // maybe exit build shell (and restart later)
   if ( !strieq (  config, gActiveConfigName ) )
   {
      exit_process ();
      clear_pbuffer ();
   }
   project_config_set_active( config );
}
Good luck,
HS2
« Last Edit: September 14, 2009, 11:56:24 PM by hs2 »

LongSteve

  • Community Member
  • Posts: 11
  • Hero Points: 1
Re: Invoke a macro when changing the active project configuration
« Reply #3 on: September 15, 2009, 09:22:28 AM »
Thanks hs2, project_config_set_active was exactly what I was after.

I should have remembered about posting version number and OS too, sorry.  It probably doesn't matter now, but it's 14.0.0.7 on Windows XP SP3.

Cheers,

Steve