Strange (using short-hands)

Casper

ProgressTalk.com Moderator
Staff member
Some time ago I encountered this strange issue that is not possible to use short-hands in a where clause. The compiler doesn't seem to know what to do with it. :)

So I started to write the where clauses in the old fashioned way:
Code:
find a where a.field = hBuffer:buffer-field('something'):buffer-value.

But now I found out that it is posible to use short-hands in a where clause.
Code:
DEFINE VARIABLE hTbuffer AS HANDLE      NO-UNDO.
DEFINE VARIABLE itmp AS INTEGER     NO-UNDO.
DEFINE TEMP-TABLE ttTest
    FIELD ROWID AS ROWID
    FIELD itnum AS INTEGER.
DEFINE BUFFER btTest FOR ttTest.
DO itmp = 1 TO 100:
    CREATE ttTest.
    ASSIGN ttTest.ROWID = ROWID(ttTest)
           ttTest.itnum = itmp.
END.
ASSIGN htBuffer = TEMP-TABLE ttTest:DEFAULT-BUFFER-HANDLE.
htBuffer:FIND-FIRST().
FIND btTest WHERE btTest.ROWID = htBuffer::ROWID.
/* FIND btTest WHERE btTest.itnum = htBuffer::itnum. */
/* FIND btTest WHERE btTest.itnum = INTEGER(htBuffer:BUFFER-FIELD("itnum"):BUFFER-VALUE). */
 
DISP btTest.itNum.

if you comment the rowid part and uncomment the itnum part you see the error when referencing an 'ordinary' field.

The last commented line is the equivalent of the short hand (which does work).

What does the compiler do in this instance, does it ignore the double colon and use ROWID as method or does it expand to buffer-field("rowid"):buffer-value?

Funny isn't it. :biggrin:

Greetz,

Casper.
 
Top