Re: VBScript Random Numbers and Letters
- From: Dr John Stockton <jrs@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 19 Jun 2005 22:46:20 +0100
JRS: In article <ea77VoFdFHA.3156@xxxxxxxxxxxxxxxxxxxx>, dated Sat, 18
Jun 2005 18:01:37, seen in news:microsoft.public.scripting.vbscript,
Richard Mueller [MVP] <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx> posted :
>
>Only call Randomize once, before the For/Next loop. I believe calling it
>more than once can make the sequence less random.
That advice is certainly good; but in a brief attempt I failed to make a
convincing demonstration in VBS on a local "Web" page and with cscript
at a DOS Prompt that doing otherwise is positively harmful.
In at least two languages, randomize loads the seed with something
permuted from the date/time, and hence will if called in a tight loop
load the same value repeatedly.
It occurs to me that by using
not seed = <scramble-time>
but seed = seed xor <scramble-time>
in the code of Randomize, the problem would not occur; perhaps VB does
this or similar ???
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
.
- Prev by Date: Hostname
- Next by Date: Re: ONCLICK Checkbox
- Previous by thread: Hostname
- Next by thread: How do I edit security on a batch of user account
- Index(es):
Relevant Pages
|