[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  If/Then/Else statements; Having trouble

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

If/Then/Else statements; Having trouble

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Kagai   (2 posts)  [Biography] bio
Date Tue 17 Nov 2009 09:00 AM (UTC)  quote  ]
Message
Alright, so I've really gotten into scripting, and my prefered method is using VBscript, easy, simple, I should know the language like the back of my hand. I create a trigger, with not one, but two if statements in it, as follows:


if EKill = "off" then
world.EnableTrigger "Balance", FALSE
else
	If eshield = "1" then
	world.send "raze @target"
	else if eprism = "1" then
	world.send "raze @target"
	else if ereflect = "1" then
	world.send "raze @target"
	Else
	world.send "wave"
	end if
end if


but I go to test it out, and it gives me this error:

Error number: -2146827274
Event: Execution of line 13 column 7
Description: Expected 'End'

Line in error:

end if
Called by: Immediate execution

But, with VB, and VBscript, even, it tries to tell me that it's the wrong way to end an If statement, but when I go and take out the "If" of end if, it gives me this message:

Error number: -2146827276
Event: Execution of line 12 column 5
Description: Expected 'If'

Line in error:

end
Called by: Immediate execution
[Go to top] top

Posted by Nick Gammon   Australia  (18,769 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 17 Nov 2009 09:34 AM (UTC)  quote  ]

Amended on Tue 17 Nov 2009 09:38 AM (UTC) by Nick Gammon

Message
Well, I count a lot more than 2 ifs there:


if EKill = "off" then
world.EnableTrigger "Balance", FALSE
else
	if eshield = "1" then
	world.send "raze @target"
	else if eprism = "1" then
	world.send "raze @target"
	else if ereflect = "1" then
	world.send "raze @target"
	Else
	world.send "wave"
	end if
end if


You need an "end if" for each if. However, if you make it "elseif" then you don't.

eg.


if EKill = "off" then
   EnableTrigger "Balance", vbFalse
else
  if eshield = "1" then
    Send "raze @target"
  elseif eprism = "1" then
    Send "raze @target"
  elseif ereflect = "1" then
    Send "raze @target"
  Else
    Send "wave"
  end if
end if


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Kagai   (2 posts)  [Biography] bio
Date Reply #2 on Tue 17 Nov 2009 09:50 AM (UTC)  quote  ]
Message
well, I've redesigned the whole thing, and realized I was just wasting my time with the first REAL if statement, and had forgotten that it was Elseif, not Else If. Thanks for the reminder.
[Go to top] 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.


2,225 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]