TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ROBERT FORTUNE
from: DAVID WILLIAMS
date: 1997-09-10 19:03:00
subject: Scramble

-> SUB Scramble (Word$)
-> LOS% = LEN(Word$)       ' the Length Of String passed
-> FOR I% = 1 TO LOS%
-> DO  SP% = INT(RND * LOS%) + 1  ' swap pointer (into the Word$ string)
-> LOOP UNTIL SP%  I%         ' no sense swapping character with self
-> Temp$ = MID$(Word$, I%, 1)   ' store this character temporarily
-> MID$(Word$, I%, 1) = MID$(Word$, SP%, 1)  ' and do the swap
-> MID$(Word$, SP%, 1) = Temp$  ' reassign char from stored temp
-> character NEXT I%
-> END SUB
Nope. This does, indeed, scramble the word, but *not* into a strictly
random order. If you do it a large number of times, you will find that
some output orders come up more often than others.
I just posted a message with a "proper" way to do it.
                          dow
--- PCBoard (R) v15.3 (OS/2) 5
---------------
* Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.