## [Clip] Re: clip to transpose two letters

Expand Messages
• ... H= Transpose ^\$StrCopy( ^\$GetSelection\$^\$GetSelection\$ ;2;2)\$ But this may be better: H= Transpose ^!Set Size=^\$GetSelSize\$ ^!InsertText
Message 1 of 8 , Mar 5, 2000
PatHanneman <kitpath@...> wrote:
>Does anyone have a clip to transpose two letters when selected?

H="Transpose"
^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;2)\$

But this may be better:

H="Transpose"
^!Set Size=^\$GetSelSize\$
^!InsertText ^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;^%Size%)\$
^!Select -^%Size%

--
Wayne M. VanWeerthuizen
Homepage: http://landru.myhome.net/wayne
• Hi Wayne, H= Transpose ^!Set Size=^\$GetSelSize\$ ^!InsertText ^\$StrCopy( ^\$GetSelection\$^\$GetSelection\$ ;2;^%Size%)\$ ^!Select -^%Size% hahaha - Thanks for the
Message 2 of 8 , Mar 5, 2000
Hi Wayne,

H="Transpose"
^!Set Size=^\$GetSelSize\$
^!InsertText ^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;^%Size%)\$
^!Select -^%Size%

hahaha - Thanks for the toy! Neat!

How to keep Jody busy for hours. :) I yours with 10 numbers and
clicked and clicked watching the numbers chase each other around.
I was fascinated. <g> I realize it was made for two digits.

Here's one for more than two. Set up the number in even sets of
however many you want.

Not: 123456789
But: 1234567890

H=Transpose2
^!Set Size=^\$GetSelSize\$
; long line
^!InsertText ^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";^\$Calc(^%Size%/2+1)\$;^%Size%)\$
^!Select -^%Size%

Thanks Wayne!-)

Happy Clip'n!
Jody

http://www.sureword.com/notetab

Subscribe, UnSubscribe, Options
mailto:Ntb-Clips-Subscribe@...
mailto:Ntb-Clips-UnSubscribe@...
http://www.egroups.com/list/ntb-clips
• ... Made for two digits? You know me better than that. It was intentional that although it works with two characters, that it also does someone possibly
Message 3 of 8 , Mar 5, 2000
Jody <KJB1611@...> wrote:
>Hi Wayne,
>
>H="Transpose"
>^!Set Size=^\$GetSelSize\$
>^!InsertText ^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;^%Size%)\$
>^!Select -^%Size%
>
>hahaha - Thanks for the toy! Neat!
>
>How to keep Jody busy for hours. :) I yours with 10 numbers and
>clicked and clicked watching the numbers chase each other around.
>I was fascinated. <g> I realize it was made for two digits.

Made for two digits? You know me better than that. It was
intentional that although it works with two characters, that it
also does someone possibly useful when more than two characters
are selected. I always try to keep my programs as widely
applicable as possible.

I should also mention that my clipbook "NoteAwk" ( which can be
found at http://landru.myhome.net/wayne/notetab.html ) contains
two clips to reverse large amounts of selected text. (One clip
reverses the text on each line. The other reverses the order
of selected lines.) It does work for transposing characters,
although it was designed to be much more powerful than that.

--
Wayne M. VanWeerthuizen
Homepage: http://landru.myhome.net/wayne
• ... Thank you. Not sure why this works. 2 is 2nd position? ...? health-e-cooking! Pat Hanneman http://home.earthlink.net/~kitpath/ Home of the Mastercook
Message 4 of 8 , Mar 5, 2000
At 03/05/2000 , Wayne VanWeerthuizen wrote:

> >Does anyone have a clip to transpose two letters when selected?
>
>H="Transpose"
>^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;2)\$
>
>But this may be better:
>
>H="Transpose"
>^!Set Size=^\$GetSelSize\$
>^!InsertText ^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;^%Size%)\$
>^!Select -^%Size%

Thank you. Not sure why this works.
"2" is 2nd position? ...?
health-e-cooking!
Home of the Mastercook Resource Network (MC's Rn)
• ... Yes 2 is 2nd position. I was hoping that how it works would be self-evident, but maybe some of my methods are a bit tricky. ... Stores selection size in
Message 5 of 8 , Mar 5, 2000
PatHanneman <kitpath@...> wrote:
>At 03/05/2000 , Wayne VanWeerthuizen wrote:
>
>> >Does anyone have a clip to transpose two letters when selected?
>>
>>H="Transpose"
>>^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;2)\$
>>
>>But this may be better:
>>
>>H="Transpose"
>>^!Set Size=^\$GetSelSize\$
>>^!InsertText ^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;^%Size%)\$
>>^!Select -^%Size%
>
>Thank you. Not sure why this works.
>"2" is 2nd position? ...?

Yes 2 is 2nd position.

I was hoping that "how it works" would be self-evident, but
maybe some of my methods are a bit tricky.

> H="Transpose"
> ^!Set Size=^\$GetSelSize\$

Stores selection size in variable so we can remember it later.
The clip is designed to work with more than just two characters.

> ^!InsertText ^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;^%Size%)\$

I always use InsertText explicitly when the clip contains other clip
commands. Although just plain:
^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;^%Size%)\$
should also work here.

^\$GetSelection\$ used twice gives us (in the clip parser's memory)
two copies of the selection one after the other. This is how I
make sure the first character being transposed follows after the
second. This is simpler than fiddling with individual characters.

^\$StrCopy("Some text";StartingPosition;Amount)\$ copies a portion
of "Some text". In our case, if the selection was originally two
characters, and we copy two characters from the 2nd position, we
get the last character from the first ^\$GetSelection\$, and the
first character from the second ^\$GetSelection\$.

When more than two characters are selected, the clip causes them
to be rotated around, the first character moving behind the last
each time.

> ^!Select -^%Size%

This command was added to make sure the text remains selection.
Since the previous command erased our selection, we needed to
store its size in a variable so we could remember it. Note that
after using ^!InsertText, the cursor is at the end of the new
text. So we use a minus symbol to select the appropriate number
of character backwards from there.

--
Wayne M. VanWeerthuizen
Homepage: http://landru.myhome.net/wayne
• Hi Pat, ^!Set Size=^\$GetSelSize\$ ^!InsertText ^\$StrCopy( ^\$GetSelection\$^\$GetSelection\$ ;2;^%Size%)\$ ^!Select -^%Size% ... Yes. Wayne used ^\$GetSelection\$
Message 6 of 8 , Mar 5, 2000
Hi Pat,

^!Set Size=^\$GetSelSize\$
^!InsertText ^\$StrCopy("^\$GetSelection\$^\$GetSelection\$";2;^%Size%)\$
^!Select -^%Size%

> Thank you. Not sure why this works.
> "2" is 2nd position? ...?

Yes. Wayne used ^\$GetSelection\$ twice for the criteria to copy
from. So, if you had 12 it would actually be 1212. He then told
it to start at index position 2 and copy the amount of characters
equaling selection size. So he was not actually reversing the
characters, but just getting the last one in the first
^\$GetSelection\$ and the first in the second ^\$GetSelection\$ and
that is what was returned. That is why if you used more than two
digits the numbers would rotate in the output instead of reverse
in say a set of 4 digits selected if you repeatedly clicked on
the clip (like me with my new toy). If you do stuff like that
often you would probably be better off getting Wayne's NoteAwk.

1212
1|21|2

In the one I did I just took the selection size and divided by 2
then added one to do the same thing, but it reverses the
characters no matter how long the sets are. I quite don't know

This
1234567890
becomes
6789012345

Happy Clip'n!
Jody

http://www.sureword.com/notetab

Subscribe, UnSubscribe, Options
mailto:Ntb-Clips-Subscribe@...
mailto:Ntb-Clips-UnSubscribe@...
http://www.egroups.com/list/ntb-clips
• ... I m still learning the language of the clip. Thank you, Wayne. pat health-e-cooking! Pat Hanneman http://home.earthlink.net/~kitpath/ Home of the
Message 7 of 8 , Mar 5, 2000
At 03/05/2000 , Wayne VanWeerthuizen wrote:
>I was hoping that "how it works" would be self-evident, but
>maybe some of my methods are a bit tricky.

I'm still learning the language of the clip. Thank you, Wayne.

pat

health-e-cooking!