Author Topic: argument() function and negative numbers  (Read 249 times)

Zaphod

  • Junior Community Member
  • Posts: 9
  • Hero Points: 2
argument() function and negative numbers
« on: September 25, 2019, 03:31:48 pm »
The argument() function (Cntl-r in Brief emulation) accepts the minus key as part of the repeat count.  While this is documented in the help for that function, it is inconvenient (for me, at least).  In Brief, and in the CodeWright Brief emulation, the minus key was treated a "command", so I could do things like "<Cntl-R>72-" to insert 72 hyphens (which I do frequently in comment blocks as a separater).
 
My knowledge of SlickEdit internals is weak, but what is the use case for allowing a negative number in the repeat count?  For example, if I type "<Cntl-r>-4<LeftArrow>", the cursor moves 1 character to the left, not 4, and not even 4 to the right.

If this really is the intended (and desired) behavior to allow negative repeat counts, then I guess I need to write a custom version of argument() that does not allow the minus character.  If there is not a good use case for negative repeat counts, can this function be fixed/enhanced/altered to only allow positive values?

[edit] FYI this appears in both SE 2016/v21 and version 24 Beta 4.
« Last Edit: September 25, 2019, 03:34:11 pm by Zaphod »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4964
  • Hero Points: 409
Re: argument() function and negative numbers
« Reply #1 on: September 26, 2019, 03:05:12 am »
The argument() command was designed to emulate emacs. For a positive argument, the command is called, argument times. For a negative number, the command is called once and has the option to do something special with the negative argument.

However, there is a bug. '-' should only be allowed as the first character. That way you can type 72-.

I'll see if we can make a hot fix for this.

Zaphod

  • Junior Community Member
  • Posts: 9
  • Hero Points: 2
Re: argument() function and negative numbers
« Reply #2 on: October 09, 2019, 08:53:19 pm »
I see this made it into 24.0.0.8.  Thanks.