This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Old posts that have not been replied to for several years.
FreakyComputer
Voice
Posts: 22 Joined: Fri May 10, 2002 8:00 pm
Location: South Africa
Post
by FreakyComputer » Sat May 11, 2002 5:35 am
Okay, this is the part I am stuck with: i have a word ie. guranga in $ogaword but now i want my script to scramble, thus making that word ie. gaanrug using ALL the letters in the $ogaword and scrambling it... If anyone can just give that little snippet of code
Thanks
FreakyComputer
slennox
Owner
Posts: 593 Joined: Sat Sep 22, 2001 8:00 pm
Contact:
Post
by slennox » Sat May 11, 2002 9:10 pm
This is adapted from my proc for randomising lists rather than strings, so it may not be the most efficient solution, but it works:
Code: Select all
proc randstring {string} {
set randstring ""
while {[string length $string] > 0} {
set random [rand [string length $string]]
append randstring [string index $string $random]
set string [string range $string 0 [expr {$random - 1}]][string range $string [expr {$random + 1}] end]
}
return $randstring
}
randstring <string>
FreakyComputer
Voice
Posts: 22 Joined: Fri May 10, 2002 8:00 pm
Location: South Africa
Post
by FreakyComputer » Sun May 12, 2002 10:38 am
Thanks you slennox
That piece of code is really what my script needed, so now my string is always scrambled! Thank you
)
FreakyComputer