How can I declare a static variable in java script
- 6 years ago
I got the solution..
initialise the variable outside the function as functionname.variable=value;
CompareClassicCAT.rowNo = 1; //static variable
CompareClassicCAT.colNo1= 2; //static variable
CompareClassicCAT.colNo2= 3; //static variable
function CompareClassicCAT(img1,img2)
{
var fileName,rowNo,colNo1,colNo2, sheetName, content;
fileName=Project.ConfigPath+"\AutoDataSource\\CATRegressionCompareTestResults.xls";
sheetName="Test_Result";
if(Regions.Compare(img1,img2))
{
CompareClassicCAT.rowNo++;
AddDataToExcelFile(fileName, sheetName, CompareClassicCAT.rowNo, CompareClassicCAT.colNo1, img1);
AddDataToExcelFile(fileName, sheetName, CompareClassicCAT.rowNo, CompareClassicCAT.colNo2, "Identical");
Log.Message(img1 + " is identical");
}
else
{
CompareClassicCAT.rowNo++;
AddDataToExcelFile(fileName, sheetName, CompareClassicCAT.rowNo, CompareClassicCAT.colNo1, img2);
AddDataToExcelFile(fileName, sheetName, CompareClassicCAT.rowNo, CompareClassicCAT.colNo2, "NOT Identical");
Log.Message(img1 + " is NOT identical");
}
}