Reply to topic  [ 6 posts ] 
A simple macro to convert case 
Author Message

Joined: 2007-07-30 12:06:49
Posts: 30
Forgive me if this is in the manual, but I cannot figure out how to do it.

I want to create a macro that consists of two steps:

1) the character to the right of the cursor is selected
2) that character's case is made lowercase.

It's nice not to have to select the character every time I want to change case.

Thanks very much.


2007-07-30 12:09:26
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
This macro should do the trick:

Code:
$selLoc = Selection Location
$selLen = Selection Length
$docLen = Selected Storage Length

# make sure there is a character to the right of the caret
Begin Perl
   if( $selLoc + $selLen < $docLen + 1 ) {
      $selLoc += $selLen;
      $selLen = 1;
   }
   else {
      $selLoc += $selLen;
      $selLen = 0;
   }
End

# make the desired character lowercase
Set Selection $selLoc, $selLen
Edit:Convert:To lowercase


2007-07-30 14:02:54
Profile WWW

Joined: 2007-07-30 12:06:49
Posts: 30
Post 
Yes, this works, though it's a bit sluggish.

I have a question though: why does Nisus make macros so tough? Most word processors give you the option to record keystrokes and create macros that way. I know writing them by hand gives you more complexity, but why not also let newbies like myself with little programming experience, do it the simple way as well?

This is a great word processor, but if I buy it, it means committing to learning the macro language and probably also perl. I just don't have the time.

Thanks.


2007-07-31 05:55:51
Profile
User avatar

Joined: 2004-12-14 07:54:49
Posts: 156
Location: Düsseldorf Germany
Post 
lawrencegoodman wrote:
Yes, this works, though it's a bit sluggish.

I have a question though: why does Nisus make macros so tough? Most word processors give you the option to record keystrokes and create macros that way. I know writing them by hand gives you more complexity, but why not also let newbies like myself with little programming experience, do it the simple way as well?

This is a great word processor, but if I buy it, it means committing to learning the macro language and probably also perl. I just don't have the time.

Thanks.


Do you remember Nisus Writer 6.5 macros? *sigh*


2007-11-09 08:21:39
Profile WWW

Joined: 2007-07-30 12:06:49
Posts: 30
Post 
This doesn't check to see if there is a character to the right, but it runs a lot quicker:

$selLoc = Selection Location
$selLen = Selection Length

Select Start
$selLen = 1
Set Selection $selLoc, $selLen
Edit:Convert:To lowercase
Select End


2007-11-12 11:49:12
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
This runs as quickly and still checks to make sure there is a character to the right:

Code:
$selLoc = Selection Location
$selLen = Selection Length
$docLen = Selected Storage Length

# make sure there is a character to the right of the caret
$selLoc += $selLen
If $selLoc <= $docLen
   $selLen = 1
Else
   $selLen = 0
End

# make the desired character lowercase
Set Selection $selLoc, $selLen
Edit:Convert:To lowercase

The reason the first macro takes longer is because of the Perl block, which are expensive to use, independent of how much actual work a particular block does.


2007-11-12 14:10:16
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software