PDA

View Full Version : [found] vs if (found)



Mike Cooper
21-Apr-2020, 04:25 PM
So I have notice in DF20, the compiler warns you if you have used and indicator that is not in brackets.

So I have taken care to replace these... but I have run across this:


This works. Right after the FIND EQ statement, the debugger shows that the record is in the buffer


Clear GT_CONTENT
Move iCourse to GT_CONTENT.COURSE_NUMBER
Move iSequence to GT_CONTENT.SEQUENCE
Find eq GT_CONTENT by Index.1
[Found] Begin
Delete GT_CONTENT
End



This doesn't work:... the record is NOT in the buffer and therefor the (found) is false and the Delete is not executed.


Clear GT_CONTENT
Move iCourse to GT_CONTENT.COURSE_NUMBER
Move iSequence to GT_CONTENT.SEQUENCE
Find eq GT_CONTENT by Index.1
if (found) Begin
Delete GT_CONTENT
End

phvwijk
21-Apr-2020, 04:49 PM
Sorry bad reading

Thought it was EQ and GT in the same ......

Peter

starzen
21-Apr-2020, 05:22 PM
you had me with these GTs also ;-)

this should work fine. double check why it is failing.

Mike Cooper
22-Apr-2020, 03:41 AM
Yeah... it was wierd because in this new small project that I am writing in DF20, I've taken care to use the newer method, and it has worked (or at least seems to work) everywhere except this one spot. When I replaced it with the old style it worked fine.

The thing was, I put a STOP on the if (found) begin line and could see by looking at the "Tables", after the Find eq the record was not in the buffer.

Mike Cooper
22-Apr-2020, 03:45 AM
And now this morning, I replaced the code back to the if (found) and it works?! I wonder if there was a non-visible character in the code that was causing the issue :confused:

Marco
22-Apr-2020, 05:24 AM
Hi mike
Did you have something in the watches that could affect the found indicator? And if so, did it fail when stepping thought the code?

Mike Cooper
22-Apr-2020, 07:10 AM
Hi Marco

I don't really ever use watches, but I did step through the code. This is where I see each step working

Clear GT_CONTENT
... I see the file is cleared
Move iCourse to GT_CONTENT.COURSE_NUMBER
Move iSequence to GT_CONTENT.SEQUENCE
... I see the values moved into the buffer
Find eq GT_CONTENT by index.1
... Here is where I expected to see the record found after this step, but in the first version ( using "if (found)") the buffer did not have the record in it. When I changed the line to the older
[found] begin, then this step caused the buffer to have the record in it.

Wierd.

M

Focus
22-Apr-2020, 08:23 AM
We haven't been playing with DF20 for very long but we have masses of code similar to this and haven't noticed (Found) not being set yet

Dennis Piccioni
22-Apr-2020, 08:34 AM
This must be a side effect of something else. Changing [found] to (found) has been our recommendation for well over a decade, I'm guessing closer to 2, so if that was broken, lots of code, including our own, would be affected.

Mike Cooper
22-Apr-2020, 09:48 AM
I think that it may be more of a case of something that is in the code that doesn't display, because deleting the line and then retyping it exactly as it was has fixed it. Also I just found (with Vincent's help) that I am having some incidents where null characters are replacing valid characters... For example, yesterday I logged where "Set Location to" is changing to "Set cation to" where the Lo is being replaced by null characters. It doesn't happen all the time but has happened to me 4 times in the last 2 days.