Scramble_Multi Words

This clip, when run on normal text scrambles the characters in 4 letter words and above without altering the formatting of the text. It leaves the first and last characters of each word unchanged but scrambles the others.

I don’t know who’s responsible for the original algorithm but a writer, he thought it might make interesting reading, located an old clip named ‘JabberWords’ thru Google.

It would scramble most words but would leave some unscrambled, to be expected when randomizing any sequence. I modified the clip so it would not leave any unscrambled words of 4 characters or greater. Although, some 4 letter words are impossible to scramble in this manner.

Words such as seek, keep, been or look and others will not change.

This is the first paragraph, above, in scrambled form;

Tihs cilp, wehn run on nmraol txet sbraelcms the crhcartaes in 4 lteetr wdors and avboe wtuohit atrneilg the fiatorntmg of the txet. It lavees the frist and lsat caarchrets of ecah wrod ucanehgnd but slmrecabs the oherts.

Scramble_Multi Words

Cut and Paste what’s between the markers.


<>------------Marker------------<>
H="Scramble_Multi"
;_ Modified-Updated~Created_20060107
;_ hrs ø hsavage·pobox·com_11:09:29p
^!ClearVariables
; -place cursor in line where scrambling to start
^!Select LINE
^!Select 0
^!Set %rowCol%=^$GetRow$:^$GetCol$
^!Set %letters%=[a-zA-Z']
^!Set %letters4%=^%letters%^%letters%^%letters%^%letters%
^!SetScreenUpdate 0
;
:LOOP
^!Find "^%letters4%+" RS
^!IfError END_LOOP
;
:BASEDUP
^!Set %baseDup%=^$GetSelection$
^!Set %baseWord%=^$GetSelection$
^!Set %baseLen%=^$StrSize(^%baseWord%)$
; checks for 4 character words and handles accordingly.
^!If ^%baseLen% = 4 NEXT ELSE SCRAMBLE
^!If ^$StrCopy("^%baseWord%";2;1)$ <> ^$StrCopy("^%baseWord%";3;1)$ SCRAMBLE
;
:REWORD
; if scrambling is passed sets newWord = baseWord
^!Set %newWord%=^%baseWord%
^!Goto PASS
;
:SCRAMBLE
^!Set %firstChar%=^$StrIndex(^%baseWord%;1)$
^!Set %lastChar%=^$StrIndex(^%baseWord%;^%baseLen%)$
^!Set %newLen%=^$Calc(^%baseLen%-2)$
^!Set %baseWord%=^$StrCopy(^%baseWord%;2;^%newLen%)$
^!Set %randSort%=^%empty%
;
:BUILD_LOOP
^!if ^%baseWord%=^%empty% END_BUILD_LOOP
^!Set %randSort%=^%randSort%< ^$StrRandom(9;01)$>^$StrIndex(^%baseWord%;1)$^%nl%
^!Set %baseWord%=^$StrCopy(^%baseWord%;2;100)$
^!Goto BUILD_LOOP
;
:END_BUILD_LOOP
^!Set %sortedBlock%=^$StrSort(^%randSort%;0;1;0)$
^!Set %randWord%=^$StrStripHTML(^%sortedBlock%;0)$
^!Set %newWord%=^%firstChar%^$StrReplace(" ";^%empty%;^%randWord%;1;0)$^%lastChar%
;
; if newWord = baseWord, jumps
^!IfSame "^%newWord%" "^%baseDup%" BASEDUP
;
:PASS
^%newWord%
^!Jump SELECT_END
^!Goto LOOP
;
:END_LOOP
^!SetScreenUpdate 1
^!SetCursor ^%rowCol%
<>------------Marker------------<>

Number of Valid Clip-lines=58

Leave a Reply

Recent Posts

Archives

Topics