[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]  Jscript
. . -> [Subject]  How to set more than two variables in script?

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

How to set more than two variables in script?

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


Posted by Saxery   (3 posts)  [Biography] bio
Date Fri 08 Oct 2004 03:12 AM (UTC)  quote  ]
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!
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 08 Oct 2004 07:27 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 08 Oct 2004 07:28 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Saxery   (3 posts)  [Biography] bio
Date Reply #3 on Fri 08 Oct 2004 10:00 AM (UTC)  quote  ]
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!
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Fri 08 Oct 2004 10:57 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Saxery   (3 posts)  [Biography] bio
Date Reply #5 on Sat 09 Oct 2004 05:01 AM (UTC)  quote  ]
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.
[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.


1,841 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]