# generator

## Recommended Posts

hello,

how can i create a hex string generator composed of 7 characters?

##### Share on other sites

Create a random number between your values, and then convert it to hex.

By default Hex numbers are 8 chars... just strip the leading 0 if your script doesn't handle it.

```For \$i=1 To 10
\$hexnum = Random(Dec('1000000'),Dec('fffffff'),1)
ConsoleWrite(Hex(\$hexnum)&@CRLF)
Next```

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

##### Share on other sites

thank you

take a look to my previous code..

\$q = Chr(Random(48 , 57)) & Chr(Random(65, 70))

\$w = Chr(Random(48, 57)) & Chr(Random(65, 70))

\$e = Chr(Random(48, 57)) & Chr(Random(65, 70))

\$r = Chr(Random(48, 57)) & Chr(Random(65, 70))

\$t = Chr(Random(48, 57)) & Chr(Random(65, 70))

\$y = Chr(Random(48, 57)) & Chr(Random(65, 70))

\$u = Chr(Random(48, 57)) & Chr(Random(65, 70))

\$string = \$q & \$w & \$e & \$r & \$t & \$y & \$u

##### Share on other sites

Well, everyone has to start somewhere.

I just need to convert from hex to dec and back fairly regularly so I'm very familiar with those functions.

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

##### Share on other sites

but its 7 characters this code generates 8 characters

##### Share on other sites

```While 1
\$String = ""
For \$i = 1 To 7
\$String &= StringRight(Hex(Random(0, 16,1)), 1)

Next
WEnd```

Regards, Rudi.

modified code, using Random() to return an integer directly.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

##### Share on other sites

By default Hex numbers are 8 chars... just strip the leading 0 if your script doesn't handle it.

Yes they are. can can use stringtrimleft() if needed.

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

thank you guys

## Create an account

Register a new account