Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 make a calendar?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
appling




PostPosted: Wed Feb 11, 2004 4:47 pm   Post subject: make a calendar?

how could i make a well-formatted calendar? i only draw the box just like this

code:

setscreen ("graphics:600;500")
locate (4, 3)
put "Sunday"
locate (4, 14)
put "Monday"
locate (4, 24)
put "Tuesday"
locate (4, 34)
put "Wednesday"
locate (4, 45)
put "Thursday"
locate (4, 56)
put "Friday"
locate (4, 66)
put "Saturday"


for i : 1 .. 6
    drawline (1, maxy div 7 * i, maxx, maxy div 7 * i, black)
    drawline (maxx div 7 * i, 1, maxx div 7 * i, maxy div 11 * 10, black)
end for
drawline (1, maxy div 11 * 10, maxx, maxy div 11 * 10, black)

but how to put the date in the box? Question Question
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Wed Feb 11, 2004 4:51 pm   Post subject: (No subject)

Draw.Text seems the simplest way to me. I'd just store dates in arrays, and run a for loop, and every time adding on the coordinates.
appling




PostPosted: Wed Feb 11, 2004 4:55 pm   Post subject: (No subject)

can u give me a simple example>?
how to make it turn to nest row or column?
Cervantes




PostPosted: Wed Feb 11, 2004 4:59 pm   Post subject: (No subject)

code:
drawbox (50, 50, 100, 100, black)
var font : int := Font.New ("serif:12")
Draw.Text ("5", 85, 85, font, black)


that's the syntax of Draw.Text... you can get that from the help file... Rolling Eyes

you should use for statements a lot for this project.
Paul




PostPosted: Wed Feb 11, 2004 5:01 pm   Post subject: (No subject)

something like this:
code:

var font := Font.New ("serif:24")
var x, y:int:=50
var dates: array 1..30 of int
for a: 1..30
dates(a):=a
end for
y:=325
for a: 1..30
Font.Draw (intstr(dates(a)), x, y, font, black)
x:=x+50
if a mod 7 = 0 then
y-=30
x:=50
end if
end for

you could do without the array here, but I only put it here so you can see, if you want to mess with it. You can mess with the coordinate increase rate to change the distances from each other.
appling




PostPosted: Wed Feb 11, 2004 5:08 pm   Post subject: (No subject)

thanks a lot, i got it
appling




PostPosted: Wed Feb 11, 2004 8:37 pm   Post subject: (No subject)

sorry, there's one thing i still do not understand.
how could i make it if the first day of the month is not beginning with monday, just like thursday or others? Sad
Delos




PostPosted: Wed Feb 11, 2004 9:10 pm   Post subject: (No subject)

Well, you know the x and y part of the Font.Draw.

Just play around with that.

My suggestion:

Consider the entire screen (or whatever part of it you are using) to be a grid...then use the x and y values to "locate" the point at which you need to put the number.
Play around a bit...you'll see.
appling




PostPosted: Wed Feb 11, 2004 9:41 pm   Post subject: (No subject)

i am not sure how to do that. this is my code
code:


setscreen ("graphics:600;540")

var font := Font.New ("serif:15")
var month, firstday : string
var dayofmonth, start, tof : int
var x, y : int := 50

put "PLEASE ENTER A MONTH:"
get month
put "THE FIRST OF THE MONTH IS WHAT DAY?"
get firstday

tof := 1
case month of
    label "february", "February", "2" :
        dayofmonth := 28
    label "january", "January", "1", "march", "March", "3", "may", "May", "5",
            "july", "July", "7", "august", "August", "8", "octaber", "Octaber",
            "10", "December", "12" :
        dayofmonth := 31
    label "april", "April", "4", "june", "June", "6", "september", "September",
            "9", "november", "November", "11" :
        dayofmonth := 30
    label :
        tof := 0
end case

case firstday of
    label "Sunday", "sunday" :
        start := 1
    label "Monday", "monday" :
        start := 2
    label "Tuesday", "tuesday" :
        start := 3
    label "Wednesday", "wednesday" :
        start := 4
    label "Thursday", "thursday" :
        start := 5
    label "Friday", "friday" :
        start := 6
    label "Saturday", "saturday" :
        start := 7
    label :
        tof := 0
end case

cls

var dates : array 1 .. dayofmonth of int
for a : 1 .. dayofmonth
    dates (a) := a
end for
y := 450
for a : 1 .. dayofmonth
    Font.Draw (intstr (dates (a)), x, y, font, black)
    x := x + 85
    if a mod 7= 0 then
        y -= 80
        x := 50
    end if
end for

locate (4, 3)
put "Sunday"
locate (4, 14)
put "Monday"
locate (4, 24)
put "Tuesday"
locate (4, 34)
put "Wednesday"
locate (4, 45)
put "Thursday"
locate (4, 56)
put "Friday"
locate (4, 66)
put "Saturday"

for i : 1 .. 4
    drawline (1, 77 * i, maxx, 77 * i, black)
end for
drawline (1, 390, maxx, 390, black)
drawline (1, 470, maxx, 470, black)
drawline (1, 500, maxx, 500, black)

for k : 1 .. 6
    drawline (round (maxx div 7 * k), 1, round (maxx div 7 * k), maxy - 40, black)
end for



if tof = 0 then
    cls
    put "are u joking??"
end if
Paul




PostPosted: Wed Feb 11, 2004 9:51 pm   Post subject: (No subject)

k thats good, but when I enter monday, it starts with sunday.
Edit: oh I see..., I think you can change the starting init value of the variable that determines the position of the text according to the days.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: