How to set more than two variables in script?

Posted by Saxery on Fri 08 Oct 2004 03:12 AM — 6 posts, 20,786 views.

#0
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!
Australia Forum Administrator #1
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.
Australia Forum Administrator #2
I don't know about your second problem. You misspelt SetVariable as setCariable, would that be the problem?
#3
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!
Australia Forum Administrator #4
Can you paste an example of the line that causes the error, and tell us what the error message is?
#5
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.