CFLib.org – Common Function Library Project

Jumble(str)

Last updated December 16, 2001

author

Brad Roberts

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Takes a string and scrambles the characters in a random fashion. If no string is given, it scrambles the default string (numbers 1-10).

Return Values:
Returns a string.

Example:

<cfset string="coldfusion">

<cfoutput>
The scrambled string is: #jumble(string)#<BR>
</cfoutput>

Parameters:

Name Description Required
str String you want to jumble. Yes

Full UDF Source:

/**
 * Takes a string and scrambles the characters.
 * 
 * @param str 	 String you want to jumble. 
 * @return Returns a string. 
 * @author Brad Roberts (broberts@nxs.net) 
 * @version 1, December 16, 2001 
 */
function jumble(str) {
  var tempstring=""; 
  var temp=0;
  while (len(str) gt 0) {
    temp = randrange(1, len(str));
    tempstring = tempstring & mid(str, temp, 1);
    str = removechars(str, temp, 1);
  }
  return tempstring;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson