DESTINEEJSH
Programmer
We need to calculate each month based on a formula. So January isn't necessarily Jan 1 - Jan 30. Also when we run February, we want January to hold the value it held when it was run in January. The same would be true for March, we would like Jan and Feb to hold the same values they had when they were run in those months.
I've created the following code and get no values.
Once I do get the values to come out, I want to put them on a bar chart. The horizonaly axis would be the months and the vertical axis would be the count.
I have four formulas. They are as follows:
===============================================
SetArray - This is in the ReportHeader
/Here we're creating the arrays we're going to use in the report. We're going to use 2 arrays. One to hold
//the month and a 'parallel' array to hold the corresponding count for that month.
Shared StringVar Array MonthIDArray := MakeArray("");
Shared NumberVar Array MonthCnts := MakeArray(0);
ReDim MonthIDArray[1];
ReDim MonthCnts[1];
//The result of a formula cannot be an array, so we
//give it something to display.
"Set Up Array"
=============================================
PopulateArrays - Detail Section
//We already dimensioned our array in the 'ArraySetup' Formula.
//To 'reference them we call the Global variable and that brings them into this formula for us to work with. We have one variable which is x, simply a counter.
Shared StringVar Array strMonthIDArray := MakeArray("");
Shared NumberVar Array intMonthCnts := MakeArray(0,0,0,0,0,0,0,0,0,0,0,0);
Shared NumberVar x := 1;
//This first part is to fill the month array with valid months
strMonthIDArray := ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
For x := 1 To Ubound(strMonthIDArray) Do
// January
If strMonthIDArray[x] = "Jan" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,01,31) and currentdate > date (2011,01,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,01,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,02,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// February
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Feb" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,02,28) and currentdate > date (2011,02,28)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,02,28) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,03,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// March
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Mar" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,03,31) and currentdate > date (2011,03,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,03,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,04,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// April
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Apr" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,04,30) and currentdate >= date (2011,04,30)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,04,30) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,05,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// May
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "May" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,05,31) and currentdate > date (2011,05,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,05,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,06,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// June
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Jun" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,06,30) and currentdate > date (2011,06,30)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,06,30) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,07,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// July
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Jul" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,07,31) and currentdate > date (2010,07,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,07,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,08,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// August
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Aug" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,08,31) and currentdate > date (2010,08,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,08,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,09,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// September
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Sep" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,09,30) and currentdate > date (2010,09,30)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,09,30) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,10,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// October
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Oct" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,10,31) and currentdate > date (2010,10,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,10,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,11,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// November
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Nov" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,11,30) and currentdate > date (2010,11,30)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,11,30) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,12,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// December
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Dec" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,12,31) and currentdate > date (2010,12,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,12,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,01,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
//Display the current Count Amt
intMonthCnts[x];
=================================
DisplayMonths - this is in the report footer section
WhilePrintingRecords;
//Call the global variable to pull our Month array into this formula.
Global StringVar Array strMonthIDArray;
//Use the join command to combine the elements of the
//array and use chr(13) as a delimiter to seperate the
//values. Chr(13) is the code for a carriage return.
//So the string we're building will have the CustomerName
//and then a carriage return so the next customer will
//display on the next line.
Join (strMonthIDArray, chr(13))
===========================================
DisplayMonthCnts - this is in the report footer section
WhilePrintingRecords;
//Call the global variable to pull our MonthCounts
array into this formula.
Global CurrencyVar Array intMonthCnts := MakeArray(0);
Global NumberVar x := 1;
StringVar strTemp;
//Loop through the OrderAmount array and build it all
//into a string. chr(13) is the code for a carriage return.
//So the string we're building, strTemp, will have the
//OrderAmount and then a carriage return so the next Order
//Amount total will display on the next line.
While x <> (UBound(intMonthCnts) + 1) Do
(
strTemp := strTemp + ToText(intMonthCnts[x]) + Chr(13);
x := x + 1
);
strTemp;
================================
Anyone know what the heck I'm doing wrong. Help, please. And I still don't know how to build the chart after I get the months and numbers to work
Debbie
I've created the following code and get no values.
Once I do get the values to come out, I want to put them on a bar chart. The horizonaly axis would be the months and the vertical axis would be the count.
I have four formulas. They are as follows:
===============================================
SetArray - This is in the ReportHeader
/Here we're creating the arrays we're going to use in the report. We're going to use 2 arrays. One to hold
//the month and a 'parallel' array to hold the corresponding count for that month.
Shared StringVar Array MonthIDArray := MakeArray("");
Shared NumberVar Array MonthCnts := MakeArray(0);
ReDim MonthIDArray[1];
ReDim MonthCnts[1];
//The result of a formula cannot be an array, so we
//give it something to display.
"Set Up Array"
=============================================
PopulateArrays - Detail Section
//We already dimensioned our array in the 'ArraySetup' Formula.
//To 'reference them we call the Global variable and that brings them into this formula for us to work with. We have one variable which is x, simply a counter.
Shared StringVar Array strMonthIDArray := MakeArray("");
Shared NumberVar Array intMonthCnts := MakeArray(0,0,0,0,0,0,0,0,0,0,0,0);
Shared NumberVar x := 1;
//This first part is to fill the month array with valid months
strMonthIDArray := ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
For x := 1 To Ubound(strMonthIDArray) Do
// January
If strMonthIDArray[x] = "Jan" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,01,31) and currentdate > date (2011,01,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,01,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,02,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// February
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Feb" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,02,28) and currentdate > date (2011,02,28)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,02,28) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,03,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// March
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Mar" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,03,31) and currentdate > date (2011,03,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,03,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,04,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// April
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Apr" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,04,30) and currentdate >= date (2011,04,30)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,04,30) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,05,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// May
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "May" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,05,31) and currentdate > date (2011,05,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,05,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,06,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// June
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Jun" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2011,06,30) and currentdate > date (2011,06,30)) or
({PAT_ENC.CONTACT_DATE} <= date (2011,06,30) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,07,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// July
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Jul" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,07,31) and currentdate > date (2010,07,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,07,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,08,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// August
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Aug" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,08,31) and currentdate > date (2010,08,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,08,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,09,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// September
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Sep" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,09,30) and currentdate > date (2010,09,30)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,09,30) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,10,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// October
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Oct" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,10,31) and currentdate > date (2010,10,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,10,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,11,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// November
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Nov" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,11,30) and currentdate > date (2010,11,30)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,11,30) and {PAT_ENC.ENC_CLOSE_DATE} > date (2010,12,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
// December
For x := 1 To Ubound(strMonthIDArray) Do
If strMonthIDArray[x] = "Dec" Then
(
if (isnull ({PAT_ENC.ENC_CLOSE_DATE}) and {PAT_ENC.CONTACT_DATE} <= date (2010,12,31) and currentdate > date (2010,12,31)) or
({PAT_ENC.CONTACT_DATE} <= date (2010,12,31) and {PAT_ENC.ENC_CLOSE_DATE} > date (2011,01,11))
then
intMonthCnts[x] := intMonthCnts[x] + 1;
Exit For;
);
//Display the current Count Amt
intMonthCnts[x];
=================================
DisplayMonths - this is in the report footer section
WhilePrintingRecords;
//Call the global variable to pull our Month array into this formula.
Global StringVar Array strMonthIDArray;
//Use the join command to combine the elements of the
//array and use chr(13) as a delimiter to seperate the
//values. Chr(13) is the code for a carriage return.
//So the string we're building will have the CustomerName
//and then a carriage return so the next customer will
//display on the next line.
Join (strMonthIDArray, chr(13))
===========================================
DisplayMonthCnts - this is in the report footer section
WhilePrintingRecords;
//Call the global variable to pull our MonthCounts
array into this formula.
Global CurrencyVar Array intMonthCnts := MakeArray(0);
Global NumberVar x := 1;
StringVar strTemp;
//Loop through the OrderAmount array and build it all
//into a string. chr(13) is the code for a carriage return.
//So the string we're building, strTemp, will have the
//OrderAmount and then a carriage return so the next Order
//Amount total will display on the next line.
While x <> (UBound(intMonthCnts) + 1) Do
(
strTemp := strTemp + ToText(intMonthCnts[x]) + Chr(13);
x := x + 1
);
strTemp;
================================
Anyone know what the heck I'm doing wrong. Help, please. And I still don't know how to build the chart after I get the months and numbers to work
Debbie