Results 1 to 10 of 10

Thread: GAH!!!! Too much tinkering and I've broke it. Help!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    1) Please fix indent of code. That is very hard to read.

    2) Why are you calling monthcheck even if the month is entered wrong?
    Code:
    if (monthNo <=0) or (monthNo >12) then
               begin
              monthcheck;
    3) Public variables and procedures are bad coding style. You should learn to use functions.

    For example monthcheck could aswell be written as:
    Code:
    function getMaxDays(month, year: integer): integer; 
    // Monthcheck as a name doesn't tell much. You can use the names for understandability
    begin
      case month of                               {This section gives the}
         4,6,9,11: result := 30;                  {months their correct lengths}
         2: if year mod 4=0 then result := 29
            else result := 28;
         else result := 31;
       end;
    end;
    4) You had monthMax instead of monthNo in the case inside monthcheck procedure.

    edit: 5) What are monthmax, monthnumber variables anyway? They aren't used or initialized anywhere.
    Last edited by User137; 18-04-2011 at 07:00 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •