"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. |