View Full Version : Fetching random lines from different text files

08-01-2011, 02:47 AM
Hey all.

I'm looking for a way to have a single, random line fetched from multiple text files, and then have that combination output somewhere, whether just to some field or another text file.

For example:

Text file A -

I like
I hate
I love
I despise
I cherish

Text file B -


Text file C -

some of the time.
most of the time.
a lot of the time.
pretty much never.

So it would go in, get a line from each, and display something like:

I love - grapefruit - most of the time.
I cherish - pineapple - some of the time.

etc. etc.

I know it's a weird-sounding example, but you get the point. The line choices don't have to be separated by hyphens, but they preferably would be separated by something, like a comma, semi-colon, slash, whatever.

I know this is pretty much a web coding forum, so that would be fine if I had to host it on my server or open it with a browser. But it would be optimal if this could be made into a standalone executable.

I'm basically looking for something like Random Line Picker (http://textmechanic.com/Random-Line-Picker.html), just with the added functionality I mentioned.

I'd be willing to make a little donation to someone if coding this would be a little difficult.


Old Pedant
08-01-2011, 03:27 AM
So you want to run this from the desktop?

On a Windows box or otherwise?

If on Windows, you can write it in JavaScript and execute it using the Windows Script Host.

But you do realize that in order to deploy it to another computer then you'd have to copy not only the code but all the text files to that other computer. And that other computer would have to be running Windows.

08-01-2011, 04:44 AM
In Windows, yes. And being able to run it locally (on one PC) is all I want.

As far as writing it in JavaScript and executing it using the Windows Script Host, I'm pretty much a coding nub. I'm essentially looking for someone with the know how to make it for me. :o

Old Pedant
08-02-2011, 08:24 PM
Send me private message.

If you don't care about it being in JS, I'll throw together an example in VBS for you that should work.