Menu

Bad code in VpData.pas

2003-03-03
2003-08-07
  • Stephan Eggermont

    The sort procedure of TVpSchedule is terrible. Instead of using the sort procedure of TList with an appropriate compare defined on TVpEvent,  some kind of bubble-sort is done with a compare on TDateTime which is called a second time if the startTime is equal.

    I hope the quality of the rest of the code is better.

     
    • Stephan Eggermont

      While looking further: this stupid code is copied to
      TVpContacts, TVpResources and TVpTasks.

      Anyone wondering about the scalability of Visual Planit?
      This is the place to make improvements.

       
    • Jeremy English

      Jeremy English - 2003-03-05

      Keep looking they use > < = to compare floating point numbers !? I had to write my own sort in the vpDayView because the event list was not always sorted correctly. Another thing to notice is that sort gets called for ever add event, instead of once after the event list is full.

       
    • Anonymous

      Anonymous - 2003-07-19

      Hi,

      I've made some changes too within the dayview component. How can we sync all our changes ?

      I'm interested in your new sort function.

      Regards,

      Edwin Dirkzwager

      CIP

       
    • Jeremy English

      Jeremy English - 2003-08-07

      Sorry it took so long for me to reply. I thought this project was dead.

      Alot of the changes that I made are not portable out side of the system that I am currently working on.

      I would have to start with the orignal version of the visual planit package and migrate most of the changes over.

      The sort that I add is straight forward here is the code:

          {Check to see if the start time is equal to the end time}
          {if so then increament the end time}
          for i := 1 to pred(EventList.Count) do
          begin
            if Eq(TVpEvent(eventlist[i]).starttime, TVpEvent(eventlist[i]).endtime) then
            begin
              TVpEvent(EventList[i]).endtime := TVpEvent(EventList[i]).endtime + getGranIncAmount(useGran);
            end;
          end;

          {The Events needed to be ordered by the start date}
          for I := 1 to pred(EventList.Count) do
          begin
            event := EventList[I];
            J := I - 1;
            sw := 0;
            while sw = 0 do
            begin
              if (event.Starttime - Trunc(event.starttime)) < (TVpEvent(EventList[J]).startTime - Trunc(TVpEvent(EventList[J]).startTime)) then
              begin
                EventList[J+1] := EventList[J];
                J := J - 1;
                if J = -1 then
                  sw := 1
              end else
                sw := 1
            end;{while}
            eventlist[J+1] := event;
          end;

      I add this to the dayview around line 2904 before the  comment:

          { Arrange this day's events in the event matrix }

      From what I understand the events are suppose to be sorted before you get to this point.  This was a few months back and I forgot the reason why this didn't work.

      You can search for j ^visualplanit at http://www.tamaracka.com/ I submitted alot of bugs and other things when the newsgroup was up.

      One thing I don't like about this package is if you want to alter the database structure you are forced to hack the code. Oh well, live and learn.

       

Log in to post a comment.