Posted: Fri Mar 04, 2011 8:00 pm Post subject: Re: help - calender
You mean that when the dates have different amount of digits, they will mess up the overall alignment?
Since the numbers only go from 1-31, you can use a simple if-structure to determine how many digits the number has and adjust the spacing according the length of the number . A code example (this is right aligned):
Turing:
for i :1.. nodays
if i < 10then put" ":12, i ..
else put" ":11, i ..
endif
%rest of for loop.... %... endfor
Also, keep in mind that the widths of the columns of your calender are inconsistent. For example, the "THURS" clolumn has two more characters than the "MON" column. This will make it harder to align as you'll need more if structures.
You might consider changing the numerical values of this line to make sure that the widths of the columns are the same :
loop put"What day does the month start on?" get day
if day ="Monday"or day ="Tuesday"or day ="Wednesday"or day ="Thursday"or day ="Friday" or day ="monday"or day ="tuesday"or day ="wednesday"or day ="thursday"or day ="friday" then else put"That is not a valid day!"
endif exitwhen day ="Monday"or day ="Tuesday"or day ="Wednesday"or day ="Thursday"or day ="Friday" or day ="monday"or day ="tuesday"or day ="wednesday"or day ="thursday"or day ="friday" endloop
put d1:10, d2:12, d3:14, d4:14, d5:14, d6:14, d7:12
if day ="Monday"or day ="monday"then for i: 1.. 6 put i:11.. endfor putskip
for i: 7.. nodays
put i:10..
daycount +=1 if(daycount =7)then putskip
daycount :=0
endif endfor endif
also, i've included a sample program of how the program should output. im testing mine with the days set to 30 and the starting date is monday.
see how it goes from 1-6 in the first row, and then starts from 7 AT sunday in the second row? i don't understand why my program isn't doing that.
Repetition3.rar
Description:
test with number of days at 30 and starting from monday.
Posted: Fri Mar 04, 2011 10:30 pm Post subject: RE:help - calender
That doesn't align because the amount of spacing for the Sunday column is different.
On all the other days, the spacing should be 10-15, whereas on Sundays the spacing is 3.
Therefore if you want to use the spacing command, you will need to use an if-structure to check if it's a Sunday. If so, you'll have to use a different amount of spacing. In your case, you will just need to check if daycount=1
whoareyou
Posted: Sat Mar 05, 2011 2:34 pm Post subject: Re: help - calender
now, i've got the sunday column all lined up, but when the numbers enter double digits, they get out of order.
also, the first row of numbers dont line up with the rest
i have to fix the column heads too; they aren't lined up with the rest of the numbers.
loop put"What day does the month start on?" get day
if day ="Monday"or day ="Tuesday"or day ="Wednesday"or day ="Thursday"or day ="Friday" or day ="monday"or day ="tuesday"or day ="wednesday"or day ="thursday"or day ="friday" then else put"That is not a valid day!"
endif exitwhen day ="Monday"or day ="Tuesday"or day ="Wednesday"or day ="Thursday"or day ="Friday" or day ="monday"or day ="tuesday"or day ="wednesday"or day ="thursday"or day ="friday" endloop