variable not detecting as number

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

variable not detecting as number

by techimac on Mon Jun 06, 2016 1:35 pm

var NumberOfLoops = 4;
var amount;

for(var z=1;z<NumberOfLoops;z++)
{

var macro = "";
iimSet("LOOPNUM", z)
macro += "CODE:" + "\n";
macro += "SET !DATASOURCE data.csv" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro += "SET !DATASOURCE_LINE {{LOOPNUM}}" + "\n";
macro += "SET !EXTRACT {{!COL1}}" + "\n";
iimPlay(macro);

amount = iimGetLastExtract();
alert (amount);
amount = amount + 100;
alert (amount);
}

if you create data.csv file with one column and few rows of data (all numbers) and run this code
you will see variable amount is concatenating '100' not doing sum.

Please tell what is wrong in the code.
It's urgent.

Thanks all

Firefox 46.0.1
VERSION BUILD=8970419
Windows 8.1
techimac
 
Posts: 189
Joined: Fri Feb 20, 2015 2:27 pm

Re: variable not detecting as number

by techimac on Mon Jun 06, 2016 1:38 pm

parseInt solved it.
techimac
 
Posts: 189
Joined: Fri Feb 20, 2015 2:27 pm


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 1 guest

-->