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 ➜ Variable Mismatch problem.

Variable Mismatch problem.

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


Posted by Gore   (207 posts)  Bio
Date Thu 26 Feb 2004 10:55 AM (UTC)
Message
What's up.. I'm having a problem with one of my variables. Here's my code:

Quote:
Sub Auto_sip (a,b,wildcard)
  Dim health
  Dim mana
  health = Wildcard(1)
  mana = Wildcard(2)
  If health < 2800 then
    If drink = 1 then
      World.Send "drink health"
      drink = 0
    End If
  End If
End Sub


The problem I'm getting is Type Mismatch: health

Any help would be appreciated, thanks!
Top

Posted by Gore   (207 posts)  Bio
Date Reply #1 on Thu 26 Feb 2004 01:19 PM (UTC)
Message
er, Also, I tried to do stuff like..

health = CInt(Wildcard(1) but I got some CInt problems, any ideas on that as well?
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #2 on Thu 26 Feb 2004 04:00 PM (UTC)
Message
Hm, if it matches on text instead of a number you could try changing the regular expression to match on a character, which is (\<IDontRememberTheCharCode:P>+), and then do a CInt perhaps?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Gore   (207 posts)  Bio
Date Reply #3 on Thu 26 Feb 2004 04:16 PM (UTC)
Message
Here's the trigger:

Quote:
<triggers>
  <trigger
   enabled="y"
   group="autobashing"
   keep_evaluating="y"
   match="^(.*?)h\, (.*?)m .*?"
   regexp="y"
   script="auto_sip"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>

Example prompt:

3387h, 2253m ex-
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #4 on Thu 26 Feb 2004 07:59 PM (UTC)
Message
Try this perhaps, although i don't know, the trigger looks fine :/

<triggers>
  <trigger
   enabled="y"
   group="autobashing"
   keep_evaluating="y"
   match="^(\d+)h\, (\d+)m"
   regexp="y"
   script="auto_sip"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>


Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 26 Feb 2004 09:31 PM (UTC)

Amended on Thu 26 Feb 2004 09:32 PM (UTC) by Nick Gammon

Message
The trigger wildcard is a string (text) and you want a number. Change the lines to read:

health = CInt (Wildcard(1))
mana = CInt (Wildcard(2))


- Nick Gammon

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

Posted by Gore   (207 posts)  Bio
Date Reply #6 on Thu 26 Feb 2004 11:06 PM (UTC)
Message
Hmm, still getting another error, here's the code, output from mud, trigger, and error:

Quote:
Sub Auto_sip (a,b,wildcard)
  Dim health, mana
  health = CInt(Wildcard(1)) 'Line 277
  mana = CInt(Wildcard(2))
  World.ColourNote "black", "white", health & " " & mana
  If health < 2800 then
    If drink = 1 then
      World.Send "drink health"
      drink = 0
    End If
  End If
End Sub

<triggers>
  <trigger
   enabled="y"
   group="autobashing"
   keep_evaluating="y"
   match="^(.*?)h\, (.*?)m *"
   regexp="y"
   script="auto_sip"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>

Error number: -2146828275
Event:        Execution of line 277 column 3
Description:  Type mismatch: 'CInt'
Called by:    Function/Sub: auto_sip called by trigger
Reason: processing trigger ""

3387h, 1746m exk-River long dead.
You see exits leading southeast and southwest.
3387h, 1746m exk-


I don't echo commands, so my prompt won't have anything after it, -until- I send something through.

Any ideas on this one? I don't understand why it's telling me type mismatch. Earlier today I looked up a vbscript reference site, and it had an example of code that was:

CInt(String -variablenamehere-)

But that didn't work either, thanks for your help again, Nick
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #7 on Fri 27 Feb 2004 04:32 AM (UTC)
Message
I put an extra line in to display wildcard 1:


note "wildcard 1 = '" & wildcard (1) & "'"


If I have the prompt on the line, I got this:


wildcard 1 = '<33/33 hp 100/100 m 110/110 mv>3387'


And, the "type mismatch" error, because it was trying to convert all that to a number.

What you may want to do is modify the regexp, to only allow numbers through, like this:


match="^(\d*?)h\, (\d*?)m .*?"


Also, the "*" means "zero or more" which may give you a match on just "h", so maybe you should use "one or more" which is "+", like this:


match="^(\d+?)h\, (\d+?)m .*?"

- Nick Gammon

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

Posted by Gore   (207 posts)  Bio
Date Reply #8 on Fri 27 Feb 2004 09:59 AM (UTC)
Message
Thanks a lot Nick, I'm not sure how that fixed it, because I had a test echo, that would echo the wildcards, and I'd always get my health and mana. But, I haven't received any errors, so thanks a lot *g*
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.


27,067 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.