TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: RONALD SCHLEGEL
from: MARVIN STAHL
date: 1997-08-11 00:00:00
subject: Re: Scramble

Hi Ron,
RS>Got a question for ya. Anyone know of a routine that will randomly 
cramble
RS>a string? Example:
RS>
RS>A$ = "test"
RS>B$ = (scramble routine)
RS>PRINT B$
RS>
RS>..and the output would be something like:
RS>estt
Try this...
--------------------------------- SNIP --------------------------------
SUB Scramble (Text$)
  IF LEN(Text$)>1 THEN                ' string must be at least 2 chars
     L=LEN(Text$)                     ' number of chars in string
     FOR I=1 TO L+L                   ' exchange 2 times len of text
       X=1+INT(RND*L)                 ' pick a random char
       Y=1+INT(RND*L)                 ' pick a second random char
       C$=MID$(Text$,X,1)             ' save original char 1 (X)
       MID$(Text$,X,1)=MID$(Text$,Y,1)' exchange char 1 with char 2 (Y)
       MID$(Text$,Y,1)=C$             ' put char 1 at position of char 2
     NEXT I                           ' till 25 (or more...) times
  END IF
END SUB                               ' done - exit subroutine
--------------------------------- SNAP --------------------------------
--- Cray Text v3.11 R
---------------
* Origin: I love the smell of gunpowder in the morning! (2:2410/330.7)

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™.