Author Topic: how to use multiple parameters for a command macro?  (Read 2236 times)

jzhao2007

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
how to use multiple parameters for a command macro?
« on: July 20, 2009, 02:43:04 pm »
Hi:
 I created a command macro with two parameters:
_command z_clean_merge(_str psQuote="",_str psDel=",")

however, in the command line ,  it seems that I can only use the first parameter like:
z-clean-merge '

how can I use more than one parameter in the command line?

thanks


Graeme

  • Senior Community Member
  • Posts: 2093
  • Hero Points: 252
Re: how to use multiple parameters for a command macro?
« Reply #1 on: July 21, 2009, 11:03:53 am »
You need to parse the command line yourself because there is no standard format for separating arguments that suits all commands.  You'll find the parse statement documented in the help.  You could do something similar to the find and replace commands when they're used on the command line  - e..g if you type c / some-search-string / some-replace-string / options   - then the replace command uses the first non blank character you type (/ in this case) as the delimiter for the strings.  On the slickedit command line, type fp replace and you'll be taken to the code for the replace function where you can see how it uses the parse statement.  If your strings don't contain embedded spaces then you don't need the special delimiter thing and you can just use spaces to separate the strings on the command line and have a parse statement like the one below.

Graeme


Code: [Select]
_command bbb(_str p1 = 'aaa', _str p2 = 'bbb') name_info(','VSARG2_CMDLINE)
{
   if (_executed_from_key_or_cmdline('bbb') ){
      typeless s1, s2;
      parse p1 with s1 s2;
      p1 = s1;
      p2 = s2;
   }
   message(p1 :+ p2);
}


jzhao2007

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: how to use multiple parameters for a command macro?
« Reply #2 on: July 22, 2009, 07:59:28 pm »
that works.

thanks