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 ➜ Jscript ➜ How to set more than two variables in script?

How to set more than two variables in script?

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


Posted by Saxery   (3 posts)  Bio
Date Fri 08 Oct 2004 03:12 AM (UTC)
Message
Hello, I am trying to familar with mushclient.It seems good. But I was muddled by the followed problem.

version: 3.5
Example:
trigger: ^>? ?(.*)\s+(.*)$
send: %1
send: script
regular expression checked
script: setVar

Here is script:
function SetVar(thename, theoutput, wildcardsVB)
{
wildcards = VBArray(wildcardsVB).toArray();

// for (i = 0; i < 10; i++)
// world.note(wildcards [i]);
world.setVariable("var1", wildcardsVB [0]);
world.setCariable("var2", wildcardsVB [1]);
}

I dont know whether the first "send" is right?It did not work correct.Does any one could give me some suggestion?

Another question:
If I set even one variable in script with other language like chinese. It work correct but will appear to me a dialog that say the chinese words hasn't been defined.I don't know whether it is the mushclient's problem or my script's problem?

Hope to know!
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 08 Oct 2004 07:27 AM (UTC)
Message
You can do it a bit more simply, like this:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^(?:&gt; )?(.*?)\s+(.*?)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ("var1", "%1");
SetVariable ("var2", "%2");
</send>
  </trigger>
</triggers>


Copy the above and hit the "paste" button in the triggers list.

Then you can capture as many variables as you like up to 9. If you want more you can use named wildcards, like this:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^(?:&gt; )?(?P&lt;foo&gt;.*?)\s+(?P&lt;bar&gt;.*?)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ("foo", "%&lt;foo&gt;");
SetVariable ("bar", "%&lt;bar&gt;");
</send>
  </trigger>
</triggers>


In this case the trigger wildcards are named "foo" and "bar" and are used to set the variables as shown. You can use this technique for many variables.

This example uses JScript as the language since that is what you had, but in VBscript it would be very very similar.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 08 Oct 2004 07:28 AM (UTC)
Message
I don't know about your second problem. You misspelt SetVariable as setCariable, would that be the problem?

- Nick Gammon

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

Posted by Saxery   (3 posts)  Bio
Date Reply #3 on Fri 08 Oct 2004 10:00 AM (UTC)
Message
Thanks for your timely help and your great work!

Now I get the point and It works correct. Another question could be solved through another way. Not the spell mistake. I mean set variable in called script not in send box like "world.SetVariable("var1", wildcardsVB [0])" . If the wildcardsVB[0] means a number it will work correct but if means a chinese word it will show error to me. I am not sure whether this is a problem. By the way I choose jscript because it makes me thought of java. Can you support java?

Thanks again!
Top

Posted by Nick Gammon   Australia  (23,169 posts)  Bio   Forum Administrator
Date Reply #4 on Fri 08 Oct 2004 10:57 PM (UTC)
Message
Can you paste an example of the line that causes the error, and tell us what the error message is?

- Nick Gammon

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

Posted by Saxery   (3 posts)  Bio
Date Reply #5 on Sat 09 Oct 2004 05:01 AM (UTC)
Message
I try it again and it works well. And I make a stupid mistake. It can set variable in script under chinese. It seems better out of my thinking. ]

I love you all.
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.


19,338 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.