Author Topic: How to do  (Read 940 times)

lusu2004

  • Community Member
  • Posts: 39
  • Hero Points: 1
How to do
« on: July 08, 2016, 05:38:54 am »
Hi Expert,

    I would like to write a macro to get current buffer name (absolute name) and line no, then invoke an external command with buffername/lineno as two arguments, is it doable?

Thanks
Lusu

hs2

  • Senior Community Member
  • Posts: 2733
  • Hero Points: 285
Re: How to do
« Reply #1 on: July 08, 2016, 07:08:17 am »
Something like this (Windows) example should work:
Code: [Select]
//! invoke cmd with current buffer name and line either in Build toolwindow or external shell
_command void cmdbl( boolean useShell = false ) name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
   _str cmdline=get_env("COMSPEC") " /k echo " maybe_quote_filename( p_buf_name ) " [line " p_RLine "]";

   useShell ? shell( cmdline, 'NAP' ) : concur_command( cmdline, false, true, false, false );
}
As commented use on SE cmdline: 'cmdbl' to run in Build toolwindow or 'cmdbl 1'  to launch cmd in external shell.

Have fun, HS2

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2501
  • Hero Points: 364
Re: How to do
« Reply #2 on: July 11, 2016, 03:37:30 pm »
You can also easily configure such a command as a Project Tool.  Project > Project Properties > Tools.  You don't have to write any code at all, and it will show up on the Build menu.

lusu2004

  • Community Member
  • Posts: 39
  • Hero Points: 1
Re: How to do
« Reply #3 on: July 12, 2016, 05:09:34 am »
Hi HS2 and Dennis,

    Thanks very much for your help! I try hs2's codes, it works well!!!

Best Regards
Lusu