Author Topic: Force upper case in alias  (Read 7729 times)

tonygray614

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Force upper case in alias
« on: August 29, 2006, 01:52:30 PM »
I have an alias that takes a parameter.  In some places in the alias text I want the parameter to be inserted as uppercase.  For example, if the alias text includes "#ifdef __%(module)__" and the module parameter is "Test", then I want the inserted text to be "#ifdef __TEST__".  Is there a way to do this?

Tony

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Force upper case in alias
« Reply #1 on: August 29, 2006, 02:39:27 PM »
See this thread:
http://community.slickedit.com/index.php?topic=242.msg936#msg936

and have look at this example:
Code: [Select]
// %\n%\x-1%\Mupcase_word %

-> inserts '// <cur. function' + moves cursor 1 char back + does upcase-word

HS2

tonygray614

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Force upper case in alias
« Reply #2 on: August 29, 2006, 05:17:31 PM »
I'm having trouble getting the syntax right.  I've tried all of the following and these are the results:

NOTE: results are shown in the quotes after the arrow ->
NOTE: module is the name of a parameter that the alias prompts for; it was set to "Test"

#ifndef __%\Mupcase_word%(module)%_H__ %   ->  "#ifndef __0(module)"
#ifndef __%\Mupcase_word(module)%_H__   ->  "#ifndef ___H__"
#ifndef __%\Mupcase_word %(module)%_H__ %   ->  "#ifndef __0(module)"
#ifndef __%\Mupcase_word module%_H__    ->  "#ifndef __0_H__"

#ifndef __%\Mupcase%(module)%_H__ %   ->  "#ifndef __(module)"
#ifndef __%\Mupcase(module)%_H__   ->  "#ifndef ___H__"
#ifndef __%\Mupcase %(module)%_H__ %   ->  "#ifndef __(module)"
#ifndef __%\Mupcase module%_H__    -> #ifndef ___H__

Tony


hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Force upper case in alias
« Reply #3 on: August 29, 2006, 06:48:46 PM »
Ok - had some troubles w/ upcase_word() too. There was always a magic '0' appended:
This works (tested):
Code: [Select]
// %\n%\mprev_word%%\mselect_word%%\mupcase_selection%%\mdeselect%

It's a bit convoluted ...
What happens:
%\n -> insert curr. function
%\mprev_word% -> goto beginning of inserted function
%\mselect_word% -> select it
%\mupcase_selection% -> finally UPCASE it (BTW: upcase(_str StringParam) is not applicable)
%\mdeselect% -> deselect

HS2

tonygray614

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Force upper case in alias
« Reply #4 on: August 29, 2006, 07:14:21 PM »
That did it!  Thanks.  BTW, I think the mysterious 0 was a return value from upcase_word.  For some reason that macro returns a 0 if sucessful.  The other upcase macros return the string.

Tony

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Force upper case in alias
« Reply #5 on: August 29, 2006, 08:03:38 PM »
You are right - I did a cross check in alias.e
Code: [Select]
...
if( !point_changed ) {
  // Text was not inserted, so use the returned string instead
  after=val:+substr(after,l+1);
...

In other words: If the specified macros doesn't move the cursor for some reason (e.g. inserting text) it's return value is inserted instead. This is good to know and also useful.
I was afraid that only 'self-inserting' macros could be used ...

HS2