break by true

Vaalen

Member
Has anybody any clue what the meaning may be of the following statement:


for each <table> where <table>.<field> = false break by true:
blabla
end.


I'm especially curious what break by true might do?

This is a part of a working source in progres 9.1E, windows.

Thnx in advance.
 

tamhas

ProgressTalk.com Sponsor
Seems stupid, but I would suppose it broke on every record. Are there any accumulate or first/last type statements inside the block?

Could be someone's misguided effort to use accumulate to produce a running total or somesuch.
 

Vaalen

Member
How could you test an first-of in this case?

If first-of(true)?

But, worse, does this break by option cause any sorting or will it be ignored?
 

tamhas

ProgressTalk.com Sponsor
Since it is silly, I've never tried it and it seems unlikely that you will find anyone else who has either. I would say there was a very high probability you could remove it and it would have no impact.
 

Casper

ProgressTalk.com Moderator
Staff member
well, some testing showed that first-of(true) shows the first record acording to the primary index.
So it seems like a very complicated way of saying find first.
well and I don't think we have to start the find first discussion again... :awink:

Casper
 

tamhas

ProgressTalk.com Sponsor
And, of course, if no sort order is indicated, _any_ for each, without the break by, will have the first record on the primary index come up first ... so no need for the break by or first of, just leave. I.e.,

Code:
for each customer no-lock:
  message "First customer is:" customer.cust-num.
  leave.
end.
 

Vaalen

Member
Found another program with a similar construction.

The comment says: /* force preselect */

Does this make any sense?
 

tamhas

ProgressTalk.com Sponsor
No. If you want preselect, say so. You've heard of "old wives tales"? Well, programmers have them too. People get strange ideas in their head and slavishly use them even when they have no basis in fact.

You can always test it. Start up one session with a loop that has the break by true; put a pause in it on the first iteration; then in another session add a record which should be selected by the for each and release the pause. If the record shows up, then there was no preselect.
 
Top