Jump to content

Recommended Posts

Posted

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!!!

Posted

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

  • 7 months later...
Posted

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
Posted

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

Posted (edited)

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

  • 8 months later...
Posted (edited)

"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
Posted

"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!
Posted

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

  • 11 years later...
Posted

You should have created your own thread instead of resurrecting this one after 10 years!

Populate your text array(s) and use Random(0, UBound($array) - 1, 1) as index to pick a random text  entry.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...