Unexpected behaviour of find-first on dynamic buffer

Posted by keesvlasblom on 31-Jan-2018 07:45

Hi all,

Maybe it has come up already in another post but I could not find it. I noticed some unexpected behaviour in a find-first on a dynamic buffer with a where clause checking on a character field. If this field contains a linefeed the find will always fail.

I've attached some sample code below.

Anyone else noticed this and can explain this or has found a workaround?

Regards

Kees Vlasblom

DEFINE TEMP-TABLE ttTest NO-UNDO
  FIELD cTest AS CHARACTER.

DEFINE BUFFER bttTest FOR ttTest.

DEFINE VARIABLE hb AS HANDLE NO-UNDO.

CREATE ttTest.
ASSIGN ttTest.ctest = "abcd~nefgh".

FIND FIRST ttTest.

FIND FIRST bttTest WHERE bttTest.ctest = ttTest.cTest NO-ERROR.

CREATE BUFFER hb FOR TABLE "ttTest".
hb:FIND-FIRST(SUBSTITUTE("WHERE cTest = '&1'", ttTest.cTest)) NO-ERROR.

MESSAGE AVAIL bttTest hb:AVAIL
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.

/* message will show: yes no */

All Replies

Posted by Stefan Drissen on 31-Jan-2018 07:59

Yes, I ran into this last month. Since ttTest.ctest should really already be inside a QUOTER function, I replaced the QUOTER function with a user defined function which does the same as QUOTER, but pulling out the CHR(10) from the string and adding it as a literal + CHR(10) + (taking start / end of string into account).

So in your case it would return QUOTER( "abcd" ) + CHR(10) + QUOTER( "efgh" )

I wasn't aware of the difference between static / dynamic since in my case a separator changed from something 'valid' to ~n

This thread is closed