Jump to content

Create Random Word or letter


Recommended Posts

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

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