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 ➜ General ➜ otherworld.SetVariable problems - VBScript

otherworld.SetVariable problems - VBScript

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


Posted by Ceramic Weasel   (2 posts)  Bio
Date Sun 15 Aug 2004 06:13 AM (UTC)
Message
I've tried this again and again in so many different ways, and I can't figure out what I'm doing wrong. I have a piece of code up the top of my VBScript file like this:

Set Volute = world.GetWorld ("Volute")
If isempty(Volute) Then
	world.Note "--- Database is not open."
Else
	world.Note "--- Database has been accessed."
End If


And that works fine. I'm able to do things like Volute.GetVariable("Blah") and Volute.SetVariable "Blah", "Blah blah blah" without any troubles.... however, when I try to use two different Volute.SetVariable lines in the same Sub, it will only do one of them:

Sub TestMe(Winner, Loser)
	WinFile = Volute.GetVariable("Stat_" & Winner)
	LosFile = Volute.GetVariable("Stat_" & Loser)
	If isempty(WinFile) Or isempty(LosFile) Then
		world.Note "--- Cannot find variable!"
		Exit Sub
	End If
	WinStat = split(WinFile, ",")
	LosStat = split(LosFile, ",")

	world.Note "--- " & Winner & " WinStat(16): " & WinStat(16)
	world.Note "--- " & Loser & " LosStat(16): " & LosStat(16)

	WinStat(16) = cint(WinStat(16)) + 3
	LosStat(16) = cint(LosStat(16)) + 1

	world.Note "--- New " & Winner & " WinStat(16): " & WinStat(16)
	world.Note "--- New " & Loser & " LosStat(16): " & LosStat(16)

	Volute.SetVariable "Stat_" & Winner, join(WinStat, ",")
	Volute.SetVariable "Stat_" & Loser, join(LosStat, ",") '<--- DOESN'T WORK!

	world.Note "--- Stat_" & Loser
End Sub


Quote:
--- janx WinStat(16): 9
--- kodax LosStat(16): 0
--- New janx WinStat(16): 12
--- New kodax LosStat(16): 1
--- Stat_kodax

--- janx WinStat(16): 12
--- kodax LosStat(16): 0
--- New janx WinStat(16): 15
--- New kodax LosStat(16): 1
--- Stat_kodax

--- janx WinStat(16): 15
--- kodax LosStat(16): 0
--- New janx WinStat(16): 18
--- New kodax LosStat(16): 1
--- Stat_kodax

--- janx WinStat(16): 18
--- kodax LosStat(16): 0
--- New janx WinStat(16): 21
--- New kodax LosStat(16): 1
--- Stat_kodax


The strange part about it is, even if I swap the two around, "Stat_" & Loser remains the one that won't set. I've checked the variable, it's there and index 16 is 0, but won't change. Anyone know what's going on here?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 16 Aug 2004 06:10 AM (UTC)
Message
It looks strange. I suggest doing two things:

1. SetVariable returns a code, check it is zero, eg.

result = Volute.SetVariable ("Stat_" & Loser, join(LosStat, ",") )

world.Note "result = " & result


2. Check what you are setting it to, like this:


world.Note "lostat = " & join(LosStat, ",")



- Nick Gammon

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

Posted by Ceramic Weasel   (2 posts)  Bio
Date Reply #2 on Mon 16 Aug 2004 01:34 PM (UTC)
Message
Crisis over.

After days of pulling my hair out, i realised i was re-setting the same variable in the parent Sub after i'd called TestMe... so it was being updated, and then being set again to the original values afterwards - A product of my bad scripting. :\
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.


10,278 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.