Jump to content

Variable isn't resetting to Zero


Talco

Recommended Posts

I'm pulling data from an external file in order to set up a chart and fill some text boxes. Each record could have between 0-13 data points for the chart, so I'm creating an array to get the data to build each chart.

 

The problem I'm running into is with the variable "i" I have set up. as it passes through the records it is set to increase to populate the array from 0-13. Then on the next record it gets reset to zero and starts over. But even after I have "Var i = 0", it basically just picks up where it left off. For example, the first record has 13 records, so i = 0 through i - 12 to fill my array. But when I get to my next record and start to build my array the variable i jumps to 13, 14, 15, and so on.

 

I can't figure out why, I'm not seeing anything in the code to tell "i" to jump to what looks to be the record number.

 

Attached is the log file to show where the variable 'jumps'.

 

Any help would be greatly appreciated!

 

If needed I can post additional files, just let me know what you need.

 

if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)
{
  Rule("OnJobStart");
}

numRecsExtBHS = externalBHS.recordCount;


var BHS_Chart = '';

var BHSArr = new Array;
var BHSHead = new Array;


chartWalker = 1
externalBHS.FindRecord(chartWalker, Field("AcctNo"))
var i = 0;
//Print ("int i " + i);
var TransID;

while (chartWalker <= numRecsExtBHS)
{

TransID = (externalBHS.GetFieldValue(chartWalker, 'AcctNo'));

   if (TransID == Field("AcctNo"))
   {     

           BHSArr[i] = NormalizeEntities(externalBHS.GetFieldValue(chartWalker, 'Consumption'));

           BHSHead[i] = NormalizeEntities(externalBHS.GetFieldValue(chartWalker, 'ReadDte')); 

   }
i++;
chartWalker++            
}
   Print ("BHSHead 0" + (BHSHead[0]))
   Print ("BHSHead 1" + (BHSHead[1]))
   Print ("BHSHead 0" + (BHSHead[2]))
   Print ("BHSHead 0" + (BHSHead[3]))
   Print ("BHSHead 0" + (BHSHead[4]))
   Print ("BHSHead 0" + (BHSHead[5]))
   Print ("BHSHead 0" + (BHSHead[6]))
   Print ("BHSHead 0" + (BHSHead[7]))
   Print ("BHSHead 8" + (BHSHead[8]))
   Print ("BHSHead 9" + (BHSHead[9]))
   Print ("BHSHead 10" + (BHSHead[10]))


   var Head1 = DateFromString(BHSHead[12]);
   var Head2 = DateFromString(BHSHead[10]);
   var Head3 = DateFromString(BHSHead[8]);
   var Head4 = DateFromString(BHSHead[6]);
   var Head5 = DateFromString(BHSHead[4]);
   var Head6 = DateFromString(BHSHead[2]);
   var Head7 = DateFromString(BHSHead[0]);
    //Print (Head1)
    //Print (Head2)
    //Print (Head3)
    //Print (Head4)
    //Print (Head5)
    //Print (Head6)
    //Print (Head7)

   FindTextFrame("Header1").content = '<span pointsize=6> <p br=false quad=R>' +  FormatDate(Head1, "sm yy") + '</span>';
   FindTextFrame("Header2").content = '<span pointsize=6> <p br=false quad=R>' +  FormatDate(Head2, "sm yy") + '</span>';
   FindTextFrame("Header3").content = '<span pointsize=6> <p br=false quad=R>' +  FormatDate(Head3, "sm yy") + '</span>';
   FindTextFrame("Header4").content = '<span pointsize=6> <p br=false quad=R>' +  FormatDate(Head4, "sm yy") + '</span>';
   FindTextFrame("Header5").content = '<span pointsize=6> <p br=false quad=R>' +  FormatDate(Head5, "sm yy") + '</span>';
   FindTextFrame("Header6").content = '<span pointsize=6> <p br=false quad=R>' +  FormatDate(Head6, "sm yy") + '</span>';
   FindTextFrame("Header7").content = '<span pointsize=6> <p br=false quad=R>' +  FormatDate(Head7, "sm yy") + '</span>';



BHS_Chart += '<row><cell>'+ BHSArr[12];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[11];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[10];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[9];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[8];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[7];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[6];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[5];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[4];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[3];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[2];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[1];
BHS_Chart += '<row><cell>' + "0";
BHS_Chart += '<row><cell>'+ BHSArr[0];
//Print(BHS_Chart)
return BHS_Chart

Link to comment
Share on other sites

I think it has to do with the fact that the "i" is incremented inside the while loop, assuming that "ChartWalker" is designed to increment up to the amount of records in the external data file. You could try replacing the if statement with a for loop and increment "i" that way and if you'd zip the data files and template, I'd be happy to tinker with it on my end if you'd prefer.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...