[Gambas-user] Issue with a Bains line

Rolf-Werner Eilert rwe-sse at osnanet.de
Thu Sep 6 09:33:57 CEST 2018


There is a strange behaviour in calculating the position of a Bains line 
over a timetable.

Long time ago, I came across this problem in my calendar program, but 
thanks to a tip by Benoit I came easily over it. To make clear what I 
mean, here is the code which runs well.

The timetable is a GridView called "wo":

wo.Row = Hour(Now)

baines.Y = wo.Current.Y - wo.ScrollY + wo.ClientY + ((wo.Current.Height 
/ 60) * Minute(Now))

The GridView just begins with 0 and runs up to 23, so it's easy: every 
hour has a cell.

Now I have a timetable for our school. Every cell has 45 minutes, and 
there are breaks between them, so you cannot compute directly from time 
to position. Instead, there is a list of starting times for each lesson.

First the current cell is set to the lesson according to the list (a 
small function does this and delivers "zeile") then:

.Row = zeile

Up to here it runs flawlessly, but then computing doesn't find a proper 
position for the Bains line:

       bains1.Y = .Current.Y - .ScrollY + .ClientY + ((.Current.Height / 
45) * Abs(CInt(DateDiff(Now, Date(Year(Now), Month(Now), Day(Now), st, 
mn, 0, 0), gb.Minute))))

This long Abs(CInt... thing runs well, I checked for it. The correct 
number of minutes from the beginning of the lesson until Now is 
delivered. Everything boils down to

bains1.Y = .CurrentY - .ScrollY + .ClientY + ((.Current.Height / 45) * 
<Number of minutes until now)

At this time of the day, the Bains line lands far behind (above) the 
cells it should be in, and later it lands too far beyond (below) them. 
It never really hits the cell or a proper position.

In the program, there are 6 GridViews with a Bains line, and the 
deviation is the same for all of them.

So where is the problem? Thank you for any hint!

Rolf


More information about the User mailing list