Sign in to follow this  
Followers 0
the_lord_mephy

Random Line?

20 posts in this topic

Is there a way to get a random line from a text file?


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites



Nope, none at all. Its not like this is a scripting language capable of advanced tasks or anything.

Honestly, was this "Ask question before thinking" day? I've just read half a dozen posts (Including another by the author of this thread) and if the authors would just think for two minutes about their question, they'd realize the answer instead of running off to the forum. Is thinking taboo?

Share this post


Link to post
Share on other sites

thanks valik, *sigh*


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

icic, ok :) here comes another question. is there a way to find the ammount of lines in a text file?


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

icic, ok :) here comes another question. is there a way to find the ammount of lines in a text file?

<{POST_SNAPBACK}>

#include <file.au3>

$cnt = _FileCountLines( $sFilePath )


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

and now for the final question. =-o can i make it so the random number is always an integer?


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

and now for the final question. =-o can i make it so the random number is always an integer?

<{POST_SNAPBACK}>

if only there were a function that returned an integer... that'd be great.

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

can i make it so the random number is always an integer?

<{POST_SNAPBACK}>

F1 (open the helpfile from your editor)...

click on search.

type Integer

Hit Enter..

Make an educated guess which function would be the best option.

try it....

:)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

RTFM

$min = 1

$max = 100

Int(Random($min, $max + 1))

Share this post


Link to post
Share on other sites

omg lol i asked three very dumb questions in a row, thanks guys


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

Hey Jon, future suggestion. Make a random function like that of Java. It can randomly generate numbers between a given range. I was making a script for Java with that earlier today.

Share this post


Link to post
Share on other sites

Hey Jon, future suggestion. Make a random function like that of Java. It can randomly generate numbers between a given range. I was making a script for Java with that earlier today.

<{POST_SNAPBACK}>

How does Java's differ from the current random function?

Share this post


Link to post
Share on other sites

You can even set max and min, you can also nest it inside a Int(). Really impressive.

Share this post


Link to post
Share on other sites

Ya, what ezzetabi said. It actually choses a random number.

Share this post


Link to post
Share on other sites

Black, are you braindead today or is it a reoccurring tragedy? ezzetabi was refering to AutoIt not java. It may hurt but you should consider thinking before you post anything.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

lol. Matt, next to Valik you are one of the funniest people on this forum :). Ah but Valik, he just has so many quotes, you still need some work :)


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

No, if you know Java look at the random funciton. It takes in int's parameters... Like 10 -20 and will chose a random number between them.

Share this post


Link to post
Share on other sites

Whats your point? That's functionally identical to:

Int(Random(10, 20))

AutoIt returns floating pointer numbers by default. If you want an Int, tell it to give you an Int by casting it to one.

Share this post


Link to post
Share on other sites

I know that... I already learned that the AutoIt random function does that after posting my first thing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0