mlloz Posted June 18, 2008 Share Posted June 18, 2008 hello, how can i create a hex string generator composed of 7 characters? Link to comment Share on other sites More sharing options...
Kerros Posted June 18, 2008 Share Posted June 18, 2008 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. Link to comment Share on other sites More sharing options...
mlloz Posted June 18, 2008 Author Share Posted June 18, 2008 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 Link to comment Share on other sites More sharing options...
Kerros Posted June 18, 2008 Share Posted June 18, 2008 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. Link to comment Share on other sites More sharing options...
mlloz Posted June 18, 2008 Author Share Posted June 18, 2008 but its 7 characters this code generates 8 characters Link to comment Share on other sites More sharing options...
rudi Posted June 18, 2008 Share Posted June 18, 2008 (edited) While 1 $String = "" For $i = 1 To 7 $String &= StringRight(Hex(Random(0, 16,1)), 1) Next MsgBox(0, "Your Hex String", $String) WEnd Regards, Rudi. [edit] modified code, using Random() to return an integer directly. Edited June 18, 2008 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Kerros Posted June 18, 2008 Share Posted June 18, 2008 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. Link to comment Share on other sites More sharing options...
mlloz Posted June 18, 2008 Author Share Posted June 18, 2008 thank you guys Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now