Dangit, I need a GOOD vbs reference site.

Posted by Magnum on Sat 05 Jan 2002 02:56 PM — 4 posts, 22,631 views.

Canada #0
Argh, another syntax error and Microsoft's site is of no use. I need a vbs book, but I don't buy books 'cause everything is on the internet, it's just a matter of finding it. :)

In the meantime, I'll ask the living VBS book, Nick:

Dear Guru, how do I get this line to work?

If Not Casting AND Not PauseCasting Then

So simple, yet so hard...
Canada #1
Sometimes, it helps not to be an idiot.

I tried:

If (Not Casting) AND (Not PauseCasting) Then

...and was stumped as to why it wasn't working. Finally, when I inserted lines before the IF statement to echo the values, I realized the STUPID error of my ways:

If (Not World.GetVariable("Casting")) AND (Not World.GetVariable("PauseCasting")) Then

I was using the wrong variables! Aaaaaaarrrgh!
Australia Forum Administrator #2
This link will probably become out-of-date one day, but try this: Microsoft's VBScript Documentation
USA #3
"Clarify your code by using local VB variables."

Huh? What did he say? What's that mean?

Well, if you're constantly gonna use the values from MUSHclient's variable collection, why not assign them to VB variables (which have the advantages of FAR shorter names and much less punctuation) to help clear things up.

Here's how I'd have written the exact same code. Sure there are more lines doing the job of the one example line, but if there was a LOT of code to come after the example, I'd end up saving a lot of typing and have some understandable code as well.

Quote:

'b stands for Boolean value. I use one-letter prefixes
' to indicate variable types. s=string, i=integer...
Dim bCasting,bPauseCasting

bCasting = World.GetVariable("Casting")
bPauseCasting = World.GetVariable("PauseCasting")

If Not (bCasting Or bPauseCasting) Then
'...stuff here...
End If


By using local VB variables, you eliminate the World.GetVariable("...") in each place you have to use it. If there's a lot of repetition, this'll clean things up quite a lot. If there's not a lot of repetition, it's often not worth the bother.