Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ World.SetVariable won't populate variable list

World.SetVariable won't populate variable list

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Wraithian   USA  (16 posts)  Bio
Date Tue 16 Dec 2003 09:14 AM (UTC)
Message
I have a script set to activate in a world open event:
 Sub WorldInit ()
World.SetVariable var1, "0"
World.SetVariable Var2, "0"
'etc
End Sub 


The problem is that my lines of variable declarations don't seem to do anything; the variables do not appear at all in the variable list. I've not tried to use them, but my assumption is: not seen, not heard (if it's not there, it can't be used).
What am I doing wrong? Oh, and by the way, option explicit is not set.
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #1 on Tue 16 Dec 2003 11:28 AM (UTC)
Message
I can think of a few things here:

1. Make sure that your WorldInit sub is declared in the corresponding world event field of the Scripting dialogue.

2. Putting parenthesis after the name of a sub that doesn't take any arguments is at the least not needed, at most - illegal. Not entirely sure however, the last time I did it was so long ago that I don't remember what happened.

3. The most likely explanation - World.SetVariable requires a string as a first agrument, e.g.:


World.SetVariable "var1", "0"


the way you do it, the script engine probably looks for an internal variable that holds an argument value, and since 'option explicit' isn't specified, it quietly ignores the entire statement.

Regarding how variables are created in Mushclient - I believe it simply creates them if they don't exist at the time of something refering to them.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 18 Dec 2003 06:24 AM (UTC)
Message
I think Ked's point 3 is correct.

You need to quote the name, eg.


World.SetVariable "var1", "0"

Assuming you don't have a variable (a VBscript variable) called "var1" then the Setvariable call is being passed an empty variant, and is failing the variable-name check, and thus is doing nothing.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,954 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.