Welcome to Phrogram Sign in | Join | Help
in Search


Calender

Last post 09-03-2008, 12:29 PM by davidw. 7 replies.
Sort Posts: Previous Next
  •  08-31-2008, 3:41 PM 7098

    Calender

    For one of our practicals we had to draw a calender with days and numbers, it didn't have to match up it just had to draw.

     

     

     Define dy As String
            Define loopdate As Int = 0
            Define done As Bool = False
            Define remainder As Int = 0
            Define column As Int = 0
            Define sat As String = ""
            Define nameofday As String = "DayName(dayofweek(today()),True)"
            ShowConsole()
            
            ConsoleWriteLine("Su\t" +  "M\t" + "T\t" + "W\t" + "T\t" + "F\t" + "S\t")
                    
            
                    
            
            For loopdate = 1 To 31
                
                remainder = loopdate Mod 7
                    
                If (remainder = 0) Then
                    consolewrite("" + loopdate + "\t")
                    ConsoleWriteLine("")
                Else
                    If (remainder <> 0) Then
                        ConsoleWrite("" + loopdate + "\t")
                        
                    End If
                End If
            Next
            
            ConsoleWriteLine("")
            ConsoleWriteLine("Program Complete...")
           

     

     

    so in my boredom I thought I would try get it be accurate, eg for August,however that didn't work too well, this is the code I have for that,

     

     

         
            //Define Date As String = Today()
            //Define theYear As Int = Year( Date )
            //Define theMonth As Int = 1
            //Define numberOfDays As Int = DaysInMonth( theYear, theMonth )
            Define Column As Int = 1
            Define loopdate As Int = 0
            Define remainder As Int = 0
            Define date As String = Today()
            Define theday As Int = DayOfWeek(date)
            Define themonth As Int = 0
            Define theyear As Int = 1
            
            ShowConsole()
            
            ConsoleWriteLine( MonthName( Month(Today()), False )+ "\t" + Today() ) //writes the month as string and date as int
            
            
            
            While Column <= 7
                ConsoleWrite( "" + DayName( Column, True ) + "\t" )
                Column = Column + 1
            End While
            ConsoleWriteLine("")
            
        //    ConsoleWriteLine(""+DaysInMonth( theYear, month(Today() )))
            themonth = 1
            For loopdate = theday To DaysInMonth(theyear,themonth)  
                    
                remainder = loopdate Mod 7
                
                If remainder = 0 Then
                    
                    ConsoleWrite("" + loopdate+ "\t")
                    ConsoleWriteLine("")
                Else
                    If remainder <>0 Then
                        ConsoleWrite("" + loopdate+ "\t")
                    End If
                End If
            Next    
                
            
        
        End Method

     

     

     

    it will display the month as a string and the date as an Int and the calender looks different from the other one so I believe I am on the right track, this is more of a muck around thing while class is on break for a few weeks.

    I don't want the answer as I won't learn anything that way, just idea as to how to get the days to line up with the correct dates.

     

    cheers  

     

  •  08-31-2008, 11:52 PM 7099 in reply to 7098

    Re: Calender

    kk have all but got it working, only prob is that if i mod the loopdate by 7 it means that my dates on the 1st line are out of sync by 1 column, if I mod by column it means that my dates on the 1st 2 line are out of sync by 5 columns, unsure of how to fix this.

     

    Define Column As Int = 1
            Define loopdate As Int = 0
            Define remainder As Int = 0
            Define date As String = Today()
            Define theday As Int = DayOfWeek(date)
            Define themonth As Int = 1
            Define theyear As Int = Year(date)
             
           
           
            ShowConsole()
            ConsoleWriteLine( MonthName( Month(Today()), False )+ "\t" + Today() ) //writes the month as string and date as int
           
           
           
            While Column <= 7   // DAYS OF THE WEEK
                ConsoleWrite( "" + DayName( Column, True ) + "\t" )
                Column = Column + 1
            End While
            ConsoleWriteLine("")
           
            Column = 1
            While Column < theDay // INDENTS THE GAPS BEFORE THE DAYS OF THE MONTH
                ConsoleWrite( "\t" )
                Column = Column + 1
            End While
           
           
                For loopdate = 1 To DaysInMonth(theyear,Month(Today() ))
                    theday = theday + 1
                   
                    remainder = loopdate Mod 7
               
                    If remainder = 0 Then
                   
                        ConsoleWrite("" + loopdate+ "\t")
                        ConsoleWriteLine("")
                    Else
                        If remainder <>0 Then
                            ConsoleWrite("" + loopdate+ "\t")
                        End If
                    End If
                   
                Next    
            
  •  09-01-2008, 2:46 AM 7100 in reply to 7099

    Re: Calender

    all working now, helps to read it when it up like this.
  •  09-01-2008, 11:34 PM 7101 in reply to 7100

    Re: Calender

    I thought it was working,however when I tried it today it made the 1st of sept as today(which is tuesday the 2nd here), so it moves the "1" of the :

    For Loopdate 1 to daysinmonth to be whatever the day is today. Im pretty sure the problem lies in these 2 lines and have tried many different alternatives but seem to  getting nowhere.

     

    Define date As String = Today()  ---- sets date as todays date

    Define theday As Int = DayOfWeek( date ) ----- tells "theday" to start from today

    I know this is the problem not quite sure how to fix it.

     

    Define Column As Int = 1
            Define loopdate As Int = 0
        //    Define remainder As Int = 0
            Define date As String = Today()
            Define themonth As Int = 1
            Define theyear As Int = Year(date)
        //    Define tempDate As String = FormatDate( theYear, theMonth, 1, False )
            Define theday As Int = DayOfWeek( date )
            Define monthdays As Int = DaysInMonth(theyear,Month(Today() ))
           
           
            ShowConsole()
            ConsoleWriteLine( MonthName( Month(Today()), False )+ "\t" +Today()) //writes the month as string and date as int
           
           
            While Column <= 7   // WRITES THE DAYS OF THE WEEK
                ConsoleWrite( "" + DayName( Column, True ) + "\t" )
                Column = Column + 1
            End While
            ConsoleWriteLine("")
           
            Column = 1
            While Column < theDay // INDENTS THE GAPS BEFORE THE DAYS OF THE MONTH
                ConsoleWrite( "\t" )
                Column = Column + 1
            End While
           
            For loopdate = 1 To monthdays//DaysInMonth(theyear,Month(Today() ))
               
                   
               
                consolewrite("" +loopdate + "\t")   
                theday = theday + 1   
                   
                    If Column = 7 Then             // KEEPS THE CALENDER DAYS IN LINE WITH THE DATE NUMBERS
                        ConsoleWriteLine( "" )  //
                        Column = 1
                    Else
                        Column = Column + 1
                    End If
                   
                Next     

     

  •  09-02-2008, 10:19 AM 7103 in reply to 7101

    Re: Calender

    I think it will change every day. It only works correct on mondays . You have to combine it with something like this:

    TheDayOfTheMonth = Day(Date)

    Michael

     

  •  09-02-2008, 3:01 PM 7106 in reply to 7103

    Re: Calender

    MichaelH:

    I think it will change every day. It only works correct on mondays . You have to combine it with something like this:

    TheDayOfTheMonth = Day(Date)

    Michael

     

    cheers dude, I am using the Phrogram User Guide and this command wasn't in it, I had tried all the commands that I thought were relevant, Is there a more up to date guide  then one I downloaded, I got it about  8-10 weeks ago

     

  •  09-03-2008, 11:57 AM 7110 in reply to 7106

    Re: Calender

    I don't think so. I found that command in the  Class Library Browser  under  Date Time .Logically it should be named DayOfMonth.

    Michael

  •  09-03-2008, 12:29 PM 7111 in reply to 7110

    Re: Calender

    What's covered in the user guide (and the Class Library Browser), in terms of descriptions of Phrogram's libraries and built-in classes, is now also in our Web-based and Windows-based help systems. We just finished these systems for v2.5 and that build should get uploaded by the end of the week.

    Here is a link to the Web-based help (use while online) - - this has not been updated yet but will be very shortly

    http://phrogram.com/phrogramhelp.htm

    Here is a link to the WIndows-based help ((download and run locally)  - - this has been updated today and is the final (part of v2.5) version

    http://phrogram.com/files/folders/phrogram_documentation/entry6983.aspx

    Filed under:
View as RSS news feed in XML