Random Generator For Free

Word Count: 305
Every since watching Elliott Sprehn's presentation on the "Internals of the Adobe CF Server" presentation at CFUnited I have become a curious hunter. Today I was playing around with the page context and I found a cool little gem. So everyone has probably needed a random number at some time for whatever reason and you have probably turned to the built in ColdFusion function randRange. While this works great and I am not certain and this is just a guess but I would think that uses java.util.random class in Java. Today I found out that that class is already available to you as part of the page context. The cool thing is there are some other methods in there that could be a big help to you. If you have ever needed a random boolean this is perfect for you. So here is a little code you can play with and the dump of the random class. Of course you could already do this by invoking the java class but why do it if its already there. If you want to learn more about the different methods just check out the api.

Comments

#1 Posted By: Steve Posted On: 6/24/08 7:02 AM
Very cool.
#2 Posted By: justin Posted On: 6/24/08 2:16 PM
I always thought it would be fun to have a random text generator that could make any combination of stuff. It could follow a few certain rules to get something *looks* like it could be a word rather than ggykwno.
#3 Posted By: Dan Vega Posted On: 6/24/08 2:20 PM |
Author Comment
If you were going to do something like that you would need some kind of dictionary service. There is no automagical way that I know of to say if(generated == validword).
#4 Posted By: Elliott Sprehn Posted On: 6/28/08 5:18 AM
Soooo happy that people are digging around in there now. My goal was to raise awareness about all the things lurking in the engine and empower CF developers.

(Hmm, trying to submit this comment the blog keeps telling me "The captcha text you have entered is incorrect." despite entering what looks to the correct text)


Post Your Comment

Leave this field empty







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.