View Single Post
  #4 (permalink)  
Old May 1st, 2009, 04:42 AM
Old Pedant Old Pedant is offline
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

*SIGH*
Quote:
VBScript Third Edition Page 615:
Syntax Randomize[Number]
Look, that is just standard "book notation" for saying that the Number argument to Randomize is *OPTIONAL*.

But you are correct: For some oddball reason, the [...] characters do *NOT* cause an error in a ".vbs" file. BUT... They also do *NOT* allow their contents to be "seen" by the VBS code!

That is, doing
Code:
Randomize [Second(Now()]
produces the same results as doing
Code:
Randomize 0
So even though they don't cause an error, they *DO* mess up your program.

But as for only getting 4 numbers in your MSGBOX: No idea what you are talking about.

When I created a "junk.vbs" file that looked like this:
Code:
Randomize
Number1 = Rnd
Number2 = Rnd
Number3 = Rnd
Number4 = Rnd
Number5 = Rnd
MsgBox Number1 & vbNewLine & Number2 & vbNewLine & Number3 & vbNewLine & Number4 & _
  vbNewLine & Number5
it worked just fine, showing all 5 random numbers in the MsgBox.

And you can confirm what I said about the [...]. Try these to VBS scripts and compare the results you get:
Code:
Randomize [Second(Time)] ' shortened form of your code
Number1 = Rnd
Number2 = Rnd
Number3 = Rnd
Number4 = Rnd
Number5 = Rnd
MsgBox Number1 & vbNewLine & Number2 & vbNewLine & Number3 & vbNewLine & Number4 & vbNewLine & Number5
and then
Code:
 Randomize 0
 Number1 = Rnd
 Number2 = Rnd
 Number3 = Rnd
 Number4 = Rnd
 Number5 = Rnd
MsgBox Number1 & vbNewLine & Number2 & vbNewLine & Number3 & vbNewLine & Number4 & vbNewLine & Number5
SO STOP USING [...]

*******************
Quote:
There are times when one wants a Character to be in a Specific Location doing a Specific Activity at a Specific Time after Game Start, every time the Computer is Turned On; but, I don't want that Psuedo-Randomness in my Video/Personal Computer Games.
Perhaps so. But then how do you MIX this capability (easy to do by, indeed, seeding Randomize with a constant, as we just saw) with truly random behavior needed in other parts of the game?

Sounds to me like you need two pseudo-random number generators, one that you tightly control and one that you just initialize with Randomize alone. But for that, you will likely have to create your own "tightly controlled" generator. Not hard, since you don't want true randomness.

********
Quote:
It is also possible that newer versions of Windows are more strict about VBScript syntax than Windows 2000 Professional
No. If you have installed MSIE version 5 or later on that machine, then you *HAVE* gotten the latest version of VBScript. The install of MSIE includes an install of both VBScript and JScript DLLs.

**********

Not sure how VBScript is going to be really useful for video game programming. It doesn't have any graphics capability, at all. If you really want to learn how to do windows-based graphic programming, I think you'd be a *LOT* better off learning VB.NET. Among other things, your games might run at decent speeds, not at the snail slow speed of VBScript.

Oh, and by the by, I use notepad for programming VBS, too. There aren't any good editors for VBS.
Reply With Quote