我怎么能解决这个等式,任何想法?

时间:2017-11-16 04:07:09

标签: imacros

我有imacros的代码 我想收到结果。

TAG POS=1 TYPE=INPUT:HIDDEN ATTR=TYPE:text&&NAME:firstNumber&&VALUE:8
TAG POS=1 TYPE=INPUT:HIDDEN ATTR=TYPE:text&&NAME:secondNumber&&VALUE:9


SET !EXTRACT_TEST_POPUP NO
SET !EXTRACT NULL
TAG POS=1 TYPE=INPUT:HIDDEN ATTR=TYPE:text&&NAME:firstNumber&&VALUE:8 EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT_TEST_POPUP NO
SET !EXTRACT NULL
TAG POS=1 TYPE=INPUT:HIDDEN ATTR=TYPE:text&&NAME:secondNumber&&VALUE:9 EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !VAR3 EVAL("var a=\"{{!VAR1}}\"; var b=\"{{!VAR2}}\"; var z = (((a + b))); z") 
PROMPT {{!VAR3}}

我已经尝试过这段代码,甚至是结果 click to see the result of imcros

任何想法如何解决。

1 个答案:

答案 0 :(得分:0)

您需要的只是在加号之前将变量解析为int。

var a = parseInt( "{{!VAR1}}" );
var b = parseInt( "{{!VAR2}}" );
var z = a + b;
z;

因此,您只需要输入源代码:

TAG POS=1 TYPE=INPUT:HIDDEN ATTR=TYPE:text&&NAME:firstNumber&&VALUE:8
TAG POS=1 TYPE=INPUT:HIDDEN ATTR=TYPE:text&&NAME:secondNumber&&VALUE:9

SET !EXTRACT_TEST_POPUP NO
SET !EXTRACT NULL
TAG POS=1 TYPE=INPUT:HIDDEN ATTR=TYPE:text&&NAME:firstNumber&&VALUE:8 EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT_TEST_POPUP NO
SET !EXTRACT NULL
TAG POS=1 TYPE=INPUT:HIDDEN ATTR=TYPE:text&&NAME:secondNumber&&VALUE:9 EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !VAR3 EVAL("var a = parseInt( "{{!VAR1}}" );var b = parseInt( "{{!VAR2}}" );var z = a + b;z") 
PROMPT {{!VAR3}}