function AddTriggerEx sciptName is not work in javascript

Posted by Spark on Sat 29 Sep 2012 06:42 AM — 5 posts, 24,905 views.

#0

long AddTriggerEx(BSTR TriggerName, BSTR MatchText, BSTR ResponseText, long Flags, short Colour, short Wildcard, BSTR SoundFileName, BSTR ScriptName, short SendTo, short Sequence); 

the parameter ScriptName is work well in lua but fail in j(ava)script.

lua:

function testaa(name, line, wilds)
 Note("Name --  " .. name)
 Note("Line --  " .. line)
 Note("wild-0  " .. wilds[0])
 Note("wild-1  " .. wilds[1])
end 

jscript:

function testaa(_n,_l,_w){
	world.note ("_n="+_n);
	world.note ("_l="+_l);
	world.note ("typeof(_w)="+typeof(_w));
	world.note ("_w="+_w);
	world.note ("_w[0]"+_w[0]);	
	world.note ("_w[1]="+_w[1]);
}  

and then i create a trigger by UI,and set pattern as "^you say:(.*)$"
,also set scriptName by "testaa",choise diffrent language,and get diffrent result
lua:

Name --  *trigger97
Line --  you say:ffasdf
wild-0  you say:ffasdf
wild-1  ffasdf

jscript:

_n=*trigger97
_l=you say:ffasdf
typeof(_w)=unknown
_w=
_w[0]undefined
_w[1]=undefined


i doubt that it is a bug . and i guess it is same to alias and triggle .
so i don't know how to solver the problem.

by the way ,i test above in ver 4.83 and v4.73,and get the same result.
Amended on Sat 29 Sep 2012 06:51 AM by Spark
Australia Forum Administrator #1
I don't see any example code that does AddTriggerEx in your post.
#2
at firsttime,i write in code,but i cannot get the variablevalue,so i create a trigger from UI for test. the code like this:

world.AddTriggerEx (
			"tmp_mapper_"+world.GetUniqueNumber (), 
			"^[>]*you say:(.*)$", 
			"",
			(17465+32768+512),//eEnabled+eTriggerRegularExpression+eIgnoreCase+eReplace+eTemporary, 
			3,//custom3, 
			1, //wildcard
			"", 
			"testaa", 
			0,//1 
			2);
Amended on Sat 29 Sep 2012 07:25 AM by Spark
#3
In lua you can access wildcards directly. In jscript you either have to turn wildcards into a VBArray or use the getTriggerWildcard method provided by mushclient.
Australia Forum Administrator #4
If you do a Note you can see what the function returned. Using your example:


Note (world.AddTriggerEx (
			"tmp_mapper_"+world.GetUniqueNumber (), 
			"^[>]*you say:(.*)$", 
			"",
			(17465+32768+512),//eEnabled+eTriggerRegularExpression+eIgnoreCase+eReplace+eTemporary, 
			3,//custom3, 
			1, //wildcard
			"", 
			"testaa", 
			0,//1 
			2));



I see 30009 (the function testaa does not exist).

Now if I add the function, like this:


function testaa(_n,_l,_w){
	world.note ("_n="+_n);
	world.note ("_l="+_l);
	world.note ("typeof(_w)="+typeof(_w));
	world.note ("_w="+_w);
	world.note ("_w[0]"+_w[0]);	
	world.note ("_w[1]="+_w[1]);
}  

Note (world.AddTriggerEx (
			"tmp_mapper_"+world.GetUniqueNumber (), 
			"^[>]*you say:(.*)$", 
			"",
			(17465+32768+512),//eEnabled+eTriggerRegularExpression+eIgnoreCase+eReplace+eTemporary, 
			3,//custom3, 
			1, //wildcard
			"", 
			"testaa", 
			0,//1 
			2));



I see 0 (success) and the trigger is added, like this:


<triggers>
  <trigger
   clipboard_arg="1"
   custom_colour="4"
   enabled="y"
   expand_variables="y"
   ignore_case="y"
   keep_evaluating="y"
   match="^[&gt;]*you say:(.*)$"
   name="tmp_mapper_265"
   one_shot="y"
   regexp="y"
   script="testaa"
   sequence="2"
   temporary="y"
   variable="tmp_mapper_265"
  >
  </trigger>
</triggers>



So, it does work.