Jump to content
Sign in to follow this  
Medic873

Create Random Word or letter

Recommended Posts

Medic873

Obviously using the random number system is quite easy. But how can I make it create random words or at least random letters.

Thank You

Share this post


Link to post
Share on other sites
Tvern

Does this help you? The key function to creating a random letter is Chr() you can look it up in the helpfile.

Local $aWordList[10] = ["word0","word1","word2","word3","word4","word5","word6","word7","word8","word9"]
ConsoleWrite("Capital = " & Chr(Random(65,90,1)) & @CRLF)
ConsoleWrite("Lowercase = " & Chr(Random(97,122,1)) & @CRLF)
ConsoleWrite("Word = " & $aWordList[Random(0,UBound($aWordList)-1,1)] & @CRLF)
Exit

Share this post


Link to post
Share on other sites
seandisanti

Does this help you? The key function to creating a random letter is Chr() you can look it up in the helpfile.

Local $aWordList[10] = ["word0","word1","word2","word3","word4","word5","word6","word7","word8","word9"]
ConsoleWrite("Capital = " & Chr(Random(65,90,1)) & @CRLF)
ConsoleWrite("Lowercase = " & Chr(Random(97,122,1)) & @CRLF)
ConsoleWrite("Word = " & $aWordList[Random(0,UBound($aWordList)-1,1)] & @CRLF)
Exit

and if you want to make sure that the result is a word, or have a word suggested based on the random letters; you can use word's spellcheck to confirm or get suggestions using com objects.

Share this post


Link to post
Share on other sites
Malkey

and if you want to make sure that the result is a word, or have a word suggested based on the random letters; you can use word's spellcheck to confirm or get suggestions using com objects.

Like this.

; http://www.autoitscript.com/forum/index.php?showtopic=20499&view=findpost&p=141586

Local $sWord, $sRes, $iCount = 0
Local $oWord = ObjCreate("Word.application")

While $iCount < 5
    For $i = 1 To Random(3, 9, 1)
        $sWord &= Chr(Random(97, 122, 1))
    Next
    If $oWord.CheckSpelling($sWord) Then
        $iCount += 1
        $sRes &= $iCount & ". Word = " & $sWord & @CRLF
        ConsoleWrite($iCount & ". Word = " & $sWord & @CRLF)
    EndIf
    $sWord = ""
WEnd
$oWord.quit
MsgBox(0, "Results", $sRes)

Share this post


Link to post
Share on other sites
seandisanti

Like this.

; http://www.autoitscript.com/forum/index.php?showtopic=20499&view=findpost&p=141586

Local $sWord, $sRes, $iCount = 0
Local $oWord = ObjCreate("Word.application")

While $iCount < 5
    For $i = 1 To Random(3, 9, 1)
        $sWord &= Chr(Random(97, 122, 1))
    Next
    If $oWord.CheckSpelling($sWord) Then
        $iCount += 1
        $sRes &= $iCount & ". Word = " & $sWord & @CRLF
        ConsoleWrite($iCount & ". Word = " & $sWord & @CRLF)
    EndIf
    $sWord = ""
WEnd
$oWord.quit
MsgBox(0, "Results", $sRes)

exactly. i had posted an example somewhere a while ago, but didn't have time to actually write something up today, thanks

Share this post


Link to post
Share on other sites
Medic873

my only thing is if I ever use this snippet on a computer without word will it work

thank you

Share this post


Link to post
Share on other sites
seandisanti

my only thing is if I ever use this snippet on a computer without word will it work

thank you

no, without word installed, word components will most definitely not work

***edit***

but if it has other office programs like excel etc; you can still use the spell check from objects created from those applications instead.

Edited by cameronsdad

Share this post


Link to post
Share on other sites
Medic873

Okay I think I found a better way to randomly generate this thank you

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.