topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 9:39 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Select Random Line from Text File  (Read 11594 times)

Verathis

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Select Random Line from Text File
« on: November 17, 2008, 07:38 PM »
I'm looking for a program that selects a random line from a text file of my choice. There was something similar done here. But I don't want the thing to increase the chance with numbers. Also, my list has 3 spaces in front of each entry due to the program I used to generate the list. :-[ Not sure if that's needed or not, since it would just be displaying a random line.

It seems simple in nature, but I'm horrible with actual programming languages, so if someone could write this up for me, I'd be very grateful. Or if it's already been done and I'm missing it, just toss me a link. I'd prefer it be an exe, but if there is a website that will eat my txt file and give me a random entry from it, that would work too!

mhb

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
  • There is no life before coffee!
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #1 on: November 18, 2008, 04:52 AM »
Hi Verathis,

just had a couple of free minutes available right now.... so here is a very simple solution:

In the AHK script you can define a default text file if you want, otherwise just call the EXE with the textfile as an argument
RandomLine_simple.exe MyQuotes.txt

I hope it helps...

Marc
There's nothing new under the sun,
but there are lots of old things we don't know. (Ambrose Bierce)

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #2 on: November 18, 2008, 08:13 AM »
I hope that this kind of software is not used for "spamming"
« Last Edit: November 18, 2008, 08:18 AM by kartal »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #3 on: November 18, 2008, 08:53 AM »
Verathis: With mhb's solution, you can also just drop the .txt file on the .exe file ;)

mhb

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
  • There is no life before coffee!
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #4 on: November 18, 2008, 08:55 AM »
Hi kartal,

I don't think this program is going to support spamming, BUT I wouldn't be too surprised if suddenly somebody new to this forum suggests a website or tool "which is really good for this purpose"  ;)

Greetings,
Marc
There's nothing new under the sun,
but there are lots of old things we don't know. (Ambrose Bierce)

Verathis

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #5 on: November 18, 2008, 05:05 PM »
Wow, that works great! Thanks a ton, everybody!

And no, it's not for spamming. Not sure how it could be used for that anyway. But I plan on writing some reviews for a friend's website, and instead of me going through and picking each and every thing each time, I figured it'd be better to have something pick it randomly, as I have a rather huge list of things I can review (1600+).

Verathis

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #6 on: November 18, 2008, 06:23 PM »
mhb, would you happen to have the source for that exe? I'm a beginner in programming, and I'd like to see how that works.

mhb

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
  • There is no life before coffee!
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #7 on: November 24, 2008, 06:44 AM »
Hi Verathis,

sorry to reply this late, but I am moving right now and had no internet access during the last days.
You can check the source code in the .ahk file, which is one of the attached downloads to my original reply. Just open that file in an editor and you have the source code...

I have to admit,  I didn't comment the code, which is really bad programming practice, but it was just a shorty :-)

Greetings,
Marc
There's nothing new under the sun,
but there are lots of old things we don't know. (Ambrose Bierce)

Verathis

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #8 on: December 01, 2008, 05:34 PM »
It's fine, I really wasn't in a hurry to get it. I'm fairly new to AHK, so I didn't know the source came in the .ahk file. Thanks for all the help!