Another SAL-philosophic question from me regarding context/focus row and MyValue

forum.centura.team.developer (1998-2005) & forum.sqlwindows (2000-2005)
StefanM
Germany
Posts: 667
Joined: 10 Aug 2018, 15:57
Location: Bavaria

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by StefanM » 01 Mar 2005, 10:41

 Posted by:  Stefan Misch 

Hi,

sorry to bother you again with this maybe somewhat esoteric question. We all
know that with table windows there is a difference between the context row
and the focus row.

If in a column class I access the value of a column using "MyValue", would
you think this should apply to the context or the focus row (first think
about it, then read on...).

It will return the column value of the context row.

I would prefer this:
- if I access the column value using the column name or handle, this should
return the value of the context row
- if I use MyValue, this should return the value of the focus row, as this
is the "cell" the user is currently working with. The context row is more
something "internal" to SAL, i.e. when populating or looping through a table
window.

What's your opinion about that?
Thanks and - No, I've not gone mad ;-)
Stefan

Thomas Lauzi

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by Thomas Lauzi » 01 Mar 2005, 10:55

 Posted by:  Thomas Lauzi 


AFAIK you always work with the context in a tablewindow. (Although it is
possible to get the columntext of the focusrow by querying the focusrow).
MyValue is a synonyom for the current value the object has and per
definition it is the value of the contextrow.
If you click on a row, the focus AND the context is set to the same row, you
never really work with the focusrow but with the contextrow.
If you move the context away (looping through the table) you must restore
the context to the old contextrow or the focusrow, otherwise you´ll access a
other row, than the focusrow.
I´m happy with the current behaviour, but your suggestion is a possible
alternative, but it wasn´t implemented by Gupta.

Regards,
Thomas L.

StefanM
Germany
Posts: 667
Joined: 10 Aug 2018, 15:57
Location: Bavaria

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by StefanM » 01 Mar 2005, 11:42

 Posted by:  Stefan Misch 

Thomas,

thanks for your feedback.

The reason why I posted this, was that I lost two days in finding a bug in
one of our class libraries, only to find out that the bug was not in the
part I wrote and modified, but somewhere deep in one of the (quite old) base
classes. The reason for this bug was, that if you click on a cell the
context row does NOT change! I verified this by putting out a string on the
status line indicating context and focus row. Up to now I have no clue what
the base classes do to prevent the context row to change to the focus row,
once you click in a cell. The column class is derived from a base class that
allows the user to type in simple expressions which will get evaluated much
like a calculator does. I guess these classes are doing some fancy stuff...

Stefan

Mirko
Italy
Posts: 983
Joined: 04 Apr 2017, 08:56
Location: Geneva

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by Mirko » 01 Mar 2005, 12:01

 Posted by:  Mirko BONANNO 

Hi Stefan,
I do expect MyValue to return the value of the context row (and this sould
not change) !!!

Concerning your class maybe it is computing a total (by moving the context
row) and (the bad programmer :-) forgot to put back the context at the focus
row ?

my 2 cents (of Euro)
Mirko

StefanM
Germany
Posts: 667
Joined: 10 Aug 2018, 15:57
Location: Bavaria

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by StefanM » 01 Mar 2005, 12:45

 Posted by:  Stefan Misch 

Hi Mirko,

yes, I hereby withdraw my "preference"...

As the context row is changed automatically once the user clicks in a cell
so that focus and context are in synch, the the context shall rule the
world...

Regarding this ominous class: there are a lot things done like WM_CHAR
trapping etc. But there is no explicit context change done. This behaviour
of "unsynched" context and focus row only occurs after the ctbl is populated
and the user makes the first few clicks and input. Then after some
interaction with the ctbl, the context and focus are are "in synch" again.

There is no fancy SAM_SetFocus/SAM_Validate stuff done, as this was likely
the cause of problems in the past.

Stefan

Mirko
Italy
Posts: 983
Joined: 04 Apr 2017, 08:56
Location: Geneva

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by Mirko » 01 Mar 2005, 14:14

 Posted by:  Mirko BONANNO 

IIRC There was incosistent behaviour for tbls when a class was derived from
an other one and the columns order was changed in the derived class (or in
the istance itself), but I'm sure you already checked this ;-)

Digging in the dark
Mirko

Karthik

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by Karthik » 02 Mar 2005, 06:38

 Posted by:  Karthik 


In our old company, it was a unwritten rule that when you are working
with table windows, the first line queries the context and the last line
puts it back. This is for even simple functions that apparently dont
change the context.

Around 20-30% of the hard-to-findbugs we discovered were because the
programmer changed the context causing centura to behave erratically.

Thanks
Karthik

Lubos Vnuk

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by Lubos Vnuk » 03 Mar 2005, 12:14

 Posted by:  Lubos Vnuk 

Hi Stefan,

Do not forget there are a few functions that may change context implicitly
e.g. SalTblFetchRow.

Regards,
Lubos.

StefanM
Germany
Posts: 667
Joined: 10 Aug 2018, 15:57
Location: Bavaria

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by StefanM » 03 Mar 2005, 19:51

 Posted by:  Stefan Misch 

Lubos,

this is exactly what I experience. In a "normal" (created a simple testvase)
ctbl once you set the focus in an editable cell, the context row is also set
to the row having the focus. This is not the case in our more complex ctbl
which is based on some classes (ctbl and col). In the calculator column
class, you can type simple expressions in a cell (+, -, * and /, but no
calculation across rows like row sum) which get evaluated much like a simple
calculator. Even though the cell has the focus, the context still "hangs" on
the last row fetched into the ctbl and so the evaluation of the expression
results in "garbage" because the underlying classes use "MyValue" which
evaluates the expression using the context row. I now work arraound this
"bug" by explicitly setting the context row to the focus row in the column
base class where the current cell value is returned using MyValue. Up to now
I not 100% sure if this is a bug in one of our classes or "feature"
introduced with TD3.1-PTF1 or the extended table window GUI. I made some
changes to the code, but not to the base classes which are in use for quite
some time and no bug was reported by the end users. We found this behaviour
in our pre-production tests.

Stefan

P.S.: The ctbl class must handle a fixed and known set of rows (<50). So the
ctbl is filled using TBL_FetchAll and the row cache is set to 100 rows and
"non-discardable".

Lubos Vnuk

Another SAL-philosophic question from me regarding context/focus row and MyValue

Post by Lubos Vnuk » 04 Mar 2005, 17:52

 Posted by:  Lubos Vnuk 

Stefan,

well, it is either a nasty TD bug or your framework problem. It is difficult
to help further unless you can produce a reasonably sized test case. I'd
suspect all the code doing explicit or implicit context change in:
SAM_Validate, SetFocus, KillFocus, SAM_Click, SAM_FetchRow,
SAM_FetchRowDone, SAM_ReportXXXX, SAM_TblDoDetails, SAM_RowSetContext,
SAM_Timer, WM_XXXX, etc.

Also, if you have some time and want to find the reason, try logging all
function and message entry points in a circular buffer and backtrack it when
you detect that Focus_row Context_row.

Take care,
Lubos.

Return to “forum.sqlwindows”

Who is online

Users browsing this forum: [Ccbot] and 0 guests