Sign in to follow this  
Followers 0
GodForsakenSoul

randomness

5 posts in this topic

#1 ·  Posted (edited)

i decided to make a random word generator, but i can't seem to be able to do ANYTHING without screwing up alot.

here's the general idea, i got angry and deleted the code so now all that is left is the idea. XD

dim $1=0
dim $11=0

$1=random([0, [26]])

select
   case $1=0
      $11=*space*
   case $1=1
      $11=a
   case $1=2
      $11=b
<repeat till you reach "case $1=26">

one letter isn't really a word, but it's a start. and i'm failing miserably at it.

this simple (though long) piece of code seems to be full of some error because it hates

the following line

case $1=1
   $11=a

and according to the help file, i can put as many cases as i want. where am i going wrong and how do i fix?

Edited by GodForsakenSoul

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Strings have to be wrapped in quotes... $11 = "b" not $11 = b.

Here's an example on something you might try:

Local $a, $b
While StringLen($a & $B) < 10;Do a loop until the desired length is there
    Switch Random(0, 26, 1)
        Case 0
            $b &= "a"
        Case 1
            $b &= "b"
        Case 2
            $a &= "zz"
        Case 3
            $a &= "yy"
        Case Else;Obviously you would continue on from the above
            $a &= "m"
    EndSwitch
WEnd
MsgBox(0, 0, $a & $B)
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You could make it simplier by using ASCII Codes.

dim $a
dim $b

$a = Random(0,26)

If $a = 0 Then 
    $b = Chr(32) ;ASCII Code for Space
Else
    $b = Chr($a + 96) ;97 - 122  =  a - z    |   65 - 90  =  A - Z
EndIf

msgbox(0,"",$B)
Edited by spudw2k

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

i decided to make a random word generator, but i can't seem to be able to do ANYTHING without screwing up alot.

here's the general idea, i got angry and deleted the code so now all that is left is the idea. XD

dim $1=0
dim $11=0

$1=random([0, [26]])

select
   case $1=0
      $11=*space*
   case $1=1
      $11=a
   case $1=2
      $11=b
<repeat till you reach "case $1=26">

one letter isn't really a word, but it's a start. and i'm failing miserably at it.

this simple (though long) piece of code seems to be full of some error because it hates

the following line

case $1=1
   $11=a

and according to the help file, i can put as many cases as i want. where am i going wrong and how do i fix?

$1=random([0, [26]]) ?????????????????????? When you see the "[" and "]" used in the help file they are being used to show optional parameters.

$1 = random(1, 26, 1)

But for just the alphabet you could also use

$1 = random(97, 122, 1)

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Do you mean something like this?

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