Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Help!

Status
Not open for further replies.

wonderlander

Instructor
Oct 19, 2001
8
0
0
GB
Firstly excuse my none technical stuff where I may use the wrong terminology.

OK I'm doing a Crystal Report that mimic's outlooks "Month View" printout.

I have a grid in the group footer with 35 "boxes" 7 days x 5 weeks.
The grid starts Monday to Sunday.

I have a an array set to allow me to store values into each of these 35 boxes.

I know what day of the week the first of the month is.
I know how many days there are in the month.

What's the tidiest way / easiest way to populate this array?

If we take December as an example it starts on a Wednesday this year and is 31 days long. I therefore wanted to store in the array nothing in positions 1 - 2 and then from the 3rd position I'd store "1" , "2" into the 4th position etc until the 33rd position in which I'd store "31". Hoping this makes sense. I also need to allow for when a month starts on a Sat or Sunday whereby depending on the number of days in the month I may need to store the 30th and 31st in Positions 1 and 2.

Any help would be greatly appreciated!
 
I didn't like the suggestion made it that link so did the following:

Calculated and assigned variables to calculate the week day that the month started on and how many days there where in the month.

I created an array 35 deep and populated as such.

whileprintingrecords;
EvaluateAfter ({@Days in Month});
numbervar array days;
numbervar daysinmonth := tonumber({@Days in Month});
numbervar firstday ;
numbervar counter :=1;
numbervar over := 1;
numbervar overby := ((daysinmonth+firstday)-35);
numbervar dayrange;

if overby >=0 then dayrange := (daysinmonth+firstday)-overby
else dayrange := (daysinmonth+firstday)-1;

while firstday <= dayrange do
(

days[firstday] := counter;
counter:=counter +1;
firstday:=firstday +1;
);

if daysinmonth+firstday > 35 then
while over < overby do
(
days[over] := counter;
counter:= counter+1;
over := over+1;
);


""



This seems to work quite happily...I'm sure people will come up with a cleaner way of doing it but I'm happy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top