AutoHotkey Community

It is currently May 27th, 2012, 10:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: March 3rd, 2008, 5:59 pm 
Offline

Joined: February 4th, 2008, 5:42 am
Posts: 4
Hello all :D . Ive finally had some time to create another free script sample that you can modify and use. This script sample randomly generators all kind of characters instead of just numbers. It also allows you to easily add more characters to the generate list.

Below is only a very basic version of the code. To view or download the full code which include help full comments,A couple more feature, more included characters visit my website at:
http://freescriptsahk.googlepages.com/Samples


Code:

Random, CharacterLength, 1, 63

lOOP
{
 Random, randomChar, 1, 4
 randomCharCount += 1

 If randomChar = 1
 {
   rc = %rc%a
 }
 else if randomChar = 2
 {
   rc = %rc%b
 }
 else if randomChar = 3
 {
   rc = %rc%c
 }
 else if randomChar = 4
 {
   rc = %rc%d
 }


 if randomCharCount = %CharacterLength%
  {
   goto, CharacterLengthReached
  }
}
return




CharacterLengthReached:
msgbox,68,[Random Charater Generator],%rc%
return

_________________
Free script samples at:
http://freescriptsahk.googlepages.com/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2008, 10:28 pm 
Wouldn't something like this be easier?

Code:
RandChar(L)
{
   CharStr := ""
   Loop % L
   {
      Random, Rand, 1, 255
      CharStr := CharStr . chr(Rand)
   }
   Return CharStr
}


MsgBox % RandChar(25)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2008, 10:34 pm 
or if you only want a certain set of characters...

Code:
RandChar(L)
{
   Characters := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
   CharStr := ""
   Loop % L
   {
      Random, Rand, 1, StrLen(Characters)
      CharStr := CharStr . SubStr(Characters, Rand, 1)
   }
   Return CharStr
}


MsgBox % RandChar(25)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 25 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group