I have a problem with Number() function on iMacros 9.0.3

Discussions and Tech Support specific to the iMacros Firefox Add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
josecuervo
Posts: 3
Joined: Wed Aug 10, 2016 10:24 am

I have a problem with Number() function on iMacros 9.0.3

Post by josecuervo » Thu Aug 18, 2016 6:24 pm

I have a problem with Number() function on iMacros 9.0.3

Here is my code:

Code: Select all

result  = "USD 0.94USD 0.94(+94.00%)";
j       = 0;
length  = 0;
while (result[j] != "(") {
    length++;
    j++;
}
buff = "";
for (k=4; k < length; k++) {
    buff += result[k];
}
mains  = Number(buff);
jMains += mains;
if (mains > 0) {
    jWin++;
} else {
    jLoss++;
}
var num = jMains;

As you see at the above code, buff variable will contains "0.94USD 0.94", and i want to make it appears to "0.94". But it just give me NaN result.

When i use iMacros 8.9.7 it works fine for me. If it's a bug from iMacros 9.0.3, is there any other way how to trick something like that?
chivracq
Posts: 9018
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: I have a problem with Number() function on iMacros 9.0.3

Post by chivracq » Thu Aug 18, 2016 9:26 pm

josecuervo wrote:I have a problem with Number() function on iMacros 9.0.3

Here is my code:

Code: Select all

result  = "USD 0.94USD 0.94(+94.00%)";
j       = 0;
length  = 0;
while (result[j] != "(") {
    length++;
    j++;
}
buff = "";
for (k=4; k < length; k++) {
    buff += result[k];
}
mains  = Number(buff);
jMains += mains;
if (mains > 0) {
    jWin++;
} else {
    jLoss++;
}
var num = jMains;

As you see at the above code, buff variable will contains "0.94USD 0.94", and i want to make it appears to "0.94". But it just give me NaN result.

When i use iMacros 8.9.7 it works fine for me. If it's a bug from iMacros 9.0.3, is there any other way how to trick something like that?
FCIM...! :mrgreen:
=> iMacros for FF v9.0.3, FF48...?, OS...?, e10s enabled/disabled...?

Dunno about possible Bug in v9.0.3 but your Construction is very cumbersome if the Aim of your complex Script is to simply isolate "0.94" from "USD 0.94USD 0.94(+94.00%)", you can do in one Statement with 2x 'split()'... (+ 'EVAL()' in '.iim').
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Tom, Tech Support
Posts: 3546
Joined: Mon May 31, 2010 4:59 pm

Re: I have a problem with Number() function on iMacros 9.0.3

Post by Tom, Tech Support » Fri Aug 19, 2016 3:50 pm

Number("0.94USD 0.94") will always result in NaN. You don't even need iMacros to test this, just open the Firefox Web Console (Ctrl+Shift+K) and enter that statement. Again, this has nothing to do with iMacros and is Javascript-specific: I get the same result (NaN) running your script regardless of which version of iMacros I use.
Regards,

Tom, iMacros Support
Post Reply