In short yes. Note a few things however:
1. Using 'call' is always prefered for 'sub' types. Without it both pure Visual Basic and VBScript will do odd things in some cases. This is because a sub called without the 'call' command is treated different that one that is called that way. Better safe than confused and even the description of why and what happens when you do it the wrong way confuses me. ;)
2. There is a difference between 'function' and 'sub'. Technically 'function' is used to return a value after a call, it only uses the 'call' command it you don't care what is returned (which is the case with most Mushclient's own script commands like world.note, where if it doesn't work, it tends to be pretty obvious. Example:
function Test(blah)
if blah = 1 then
Test = blah
world.note blah
end if
end function
sub Test(blah)
if blah = 1 then
world.note blah
end if
end sub
You could call these like:
Variable = Test(MyValue)
and
call Test(MyValue)
The first version would return nothing if 'blah' was anything except 1, or 1 if it is, and place the result in your variable. This is convenient for things like a color calculator I use that requires the same large batch of code to be called up to 12 times in the same script and returns a HTML color string. The second version just performs a task and returns without any result. Unless you have to return some value or you need to return an error so that you know if something worked, you probably won't need the 'Variable = sub' version.
3. The 'name' of the variable does not need to be the same in the sub declaration as in the call. VBScript only cares that you pass the correct number and real languages that allow you to specifically tell it the type, like 'integer' or 'string', only care that what you send the sub or function is the same type and in the right order. This lets you give the variable a name that makes sense for that subroutine, but may be called something else in the one calling it. Example:
sub List
for count = 0 to 19
call Show(Weapons(count))
next
end sub
sub Show(Weapon)
world.colournote "Purple","Black",Weapon
end sub
This is a simple example, but the idea is that since you are only dealing with one 'weapon' at a time in Show, it makes sense to use that name there, even though the call uses an array called 'Weapons'. |