Jump to content
Sign in to follow this  
logmein

Random text

Recommended Posts

logmein

Parameters

$length : the max length of string

$number : 1 include numer; 0 not include

Return value

Suceed : Random string

Failure : -1

While 1
    Sleep (1000)
    ConsoleWrite (_RandomText (10,1) & @CRLF)
WEnd

Func _RandomText ($length,$number)
    Local $return
    Local $n[36] = ['q','w','e','r','t','y','u','i','o','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','p','1','2','3','4','5','6','7','8','9','0']

    
    If $number = '' or $number = 0 Then
        For $i = 1 to $length
            $return &= $n[Random (0,26,1)]
        Next
        Return $return
    ElseIf $number = 1
        For $i = 1 to $length
            $return &= $n[Random (0,35,1)]
        Next
        Return $return
    Else
        Return -1
    EndIf
    
    
EndFunc

All comments are welcome!!!

Share this post


Link to post
Share on other sites
corgano

Might want to look at this in a new light...

While 1
    Sleep(1000)
    ConsoleWrite(_RandomText(10) & @CRLF)
WEnd

Func _RandomText($length)
    $text = ""
    For $i = 1 To $length
        $text &= Chr(Random(65, 90, 1))
    Next
    Return $text
EndFunc   ;==>_RandomText

8)

Just wanted to point out what he did. (For anyone new who sees this)

Instead of haveing a array of letters, he had it pick a random number (between the one assinged to a and the one assinged to z) and had it convert the number to the leter it represents. It repeats this untill it has the required amount of letters.


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
Rogue5099

Upper and lower case letters...

While 1
    Sleep(1000)
    ConsoleWrite(_RandomText(10) & @CRLF)
WEnd

Func _RandomText($length)
    $text = ""
    For $i = 1 To $length
        $temp = Random(65, 122, 1)
        While $temp >= 90 And $temp <= 96
            $temp = Random(65, 122, 1)
        WEnd
        $temp = Chr($temp)
        $text &= $temp
    Next
    Return $text
EndFunc   ;==>_RandomText

Share this post


Link to post
Share on other sites
Minikori

Text cannot be random, other wise it wouldn't be text.

LCBHkhvcgjkyBKcy

Mind blown?


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites
NerdFencer

Upper and lower case letters...

While 1
    Sleep(1000)
    ConsoleWrite(_RandomText(10) & @CRLF)
WEnd

Func _RandomText($length)
    $text = ""
    For $i = 1 To $length
        $temp = Random(65, 122, 1)
        While $temp >= 90 And $temp <= 96
            $temp = Random(65, 122, 1)
        WEnd
        $temp = Chr($temp)
        $text &= $temp
    Next
    Return $text
EndFunc   ;==>_RandomText

You are over-thinking the issue, let the numbers do the work for you. (Upper and Lower)

I also made it conform to MustDeclareVars (about 25% faster)

While 1
    Sleep(1000)
    ConsoleWrite(_RandomText(10) & @CRLF)
WEnd

Func _RandomText($length)
    Local $text = "", $temp
    For $i = 1 To $length
        $temp = Random(65, 116, 1)
        $text&= Chr($temp+6*($temp>90))
    Next
    Return $text
EndFunc   ;==>_RandomText

Here is another version that includes numbers as well.

While 1
    Sleep(1000)
    ConsoleWrite(_RandomText(10) & @CRLF)
WEnd

Func _RandomText($length)
    Local $text = "", $temp
    For $i = 1 To $length
        $temp = Random(55, 116, 1)
        $text&= Chr($temp+6*($temp>90)-7*($temp<65))
    Next
    Return $text
EndFunc   ;==>_RandomText

Edit: added (about 25% faster) from my quick side-by-side speed test

Edited by NerdFencer

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites
engjcowi

anyway we can have quote of the day?? or random quote?

Edited by engjcowi

Drunken Frat-Boy Monkey Garbage

Share this post


Link to post
Share on other sites
jaberwacky

"It is mankind's discovery of language which more than any other single thing has separated him from the animal creation. Without language, what concept have we of past or future as separated from the immediate present? Without language, how can we tell anyone what we feel, or what we think? It might be said that until he developed language, man had no soul, for without language how could he reach deep inside himself and discover the truths that are hidden there, or find out what emotions he shared, or did not share, with his fellow men and women. But because this greatest gift of all gifts is in daily use, and is smeared, and battered and trivialized by commonplace associations, we too often forget the splendour of which it is capable, and the pleasures that it can give, from the pen of a master. "

- Robertson Davies

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites
czardas

"It is mankind's discovery of language which more than any other single thing has separated him from the animal creation. Without language, what concept have we of past or future as separated from the immediate present? Without language, how can we tell anyone what we feel, or what we think? It might be said that until he developed language, man had no soul, for without language how could he reach deep inside himself and discover the truths that are hidden there, or find out what emotions he shared, or did not share, with his fellow men and women. But because this greatest gift of all gifts is in daily use, and is smeared, and battered and trivialized by commonplace associations, we too often forget the splendour of which it is capable, and the pleasures that it can give, from the pen of a master. "

- Robertson Davies

Well I disagree with Robertson Davies. Language wasn't discovered, it evolves. It's also not unique to mankind. I guess this is more a topic for the chat forum. Hmm!

Share this post


Link to post
Share on other sites
engjcowi

Lol i was hoping the program could be adapted to give a random quote so i could then have a quote of the day. Ive got a load i could make a text or ini file. But thank you for that quote ill add it to my collection


Drunken Frat-Boy Monkey Garbage

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.