View Full Version : Randomize in C++ Or VB
outlawstar4761
February 23rd, 2006, 11:42 PM
I know that in JavaScript there is an object that can give "random" results. Would it be possible to write a program in C++ or visual basic that will scan the contents of a folder and sub folders (or just a folder) and the program send me back a random file? Not neccessarly open it, just give the name.
Thanks.
RewtGuy
February 24th, 2006, 03:37 AM
Yeah It's possible.
root
February 24th, 2006, 11:23 AM
BV has a randomise function for generating random numbers within limits...
so yes...
find out how many file are in the folder..
generate a random number (e.g five) and return that file (e.g the five filename).
RewtGuy
February 24th, 2006, 07:37 PM
I don't know what libaray / function can read file names from a directory in windows.
For Linux it's opendir readdir and closedir. if you don't know how to use it, man them. What I'd do is put the file names into an array. use a random number function (there's a lot out there) and you can adjust what you get by using the % operator. then assign the variable to the random number, then stick it in the array [x]; and get the x element.
Ð88
February 26th, 2006, 03:40 PM
I don't know what libaray / function can read file names from a directory in windows.
For Linux it's opendir readdir and closedir. if you don't know how to use it, man them. What I'd do is put the file names into an array. use a random number function (there's a lot out there) and you can adjust what you get by using the % operator. then assign the variable to the random number, then stick it in the array [x]; and get the x element.
yeah in a case like that you can use the rand() or srand() functions to get the random effect.
Argon
April 3rd, 2006, 01:51 PM
For VB, I know there is the Rnd function, but this produces the same random sequence every time a program is executed. Is there any way, perhaps a different function, that would produce different sequences of random numbers every time a program is run? Thanks.
outlawstar4761
April 3rd, 2006, 07:52 PM
You can do it with JS.
That's what I used to write the program I was trying to make when I posted this thread
RewtGuy
April 4th, 2006, 09:27 AM
not as bad as some but this post was still a month old. hmm...
j03
April 9th, 2006, 12:27 PM
About two months a made a Cheesy program: "Rannum - For all your random need's" That made random Numbers... Cant rember how... (It was in VB)
Powered by vBulletin™ Version 4.0.6 Copyright © 2010 vBulletin Solutions, Inc. All rights reserved.