Macro that shows how to generate a random string

Share your macros, knowledge, solutions, services, ...
Post Reply
Petr
Posts: 106
Joined: Tue Oct 18, 2016 1:12 pm

Macro that shows how to generate a random string

Post by Petr » Tue Dec 13, 2016 7:21 pm

This macro generates a random string 12 characters long. The string consists from lower case characters.

Code: Select all

<cmds>
<#>Define the set of charactrs that can show up in random string
<var_parse>("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,v,w,x,y,z",",","",vChars,vCharsSize)
<varset>("vRandStr=%_vStrEmpty%","")

<#>Repeat 12 times to get random string 12 characters long
<for>("i=0","i<12","1")
   <#>Get random number
   <var_oper>(vRandNum,"",RANDOM_NUMBER,"%vCharsSize%","","")
   <#>Pick character on this position from the defined set
   <varset>("vRandChar=%vChars[vRandNum]%","")
   <#>Append to the random string
   <varset>("vRandStr=%vRandStr%%vRandChar%","")
<for_end>

<msg>(-100,-100,"%vRandStr%","Random string 12 characters long",1,0,0,0)

Post Reply