Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • August 31, 2015, 10:59:32 PM
  • Proudly celebrating 10 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 6529 times)

Verathis

  • Participant
  • Joined in 2008
  • *
  • gravatar avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Select Random Line from Text File
« on: November 17, 2008, 07:38:56 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:15 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
Code: [Select]
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:59 AM »
I hope that this kind of software is not used for "spamming"
« Last Edit: November 18, 2008, 08:18:07 AM by kartal »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Select Random Line from Text File
« Reply #3 on: November 18, 2008, 08:53:34 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:03 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
  • *
  • gravatar avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #5 on: November 18, 2008, 05:05:26 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
  • *
  • gravatar avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #6 on: November 18, 2008, 06:23:51 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:39 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
  • *
  • gravatar avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: Select Random Line from Text File
« Reply #8 on: December 01, 2008, 05:34:50 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!