[progress Communities] [progress Openedge Abl] Forum Post: Re: [solved] Break Keyword Or By...

  • Thread starter Thread starter smat-consulting
  • Start date Start date
Status
Not open for further replies.
S

smat-consulting

Guest
Good observation, Marco! I apologize, Joseph, for using your draft code to make the below points... coding-style is just a pet-peeve of mine... I do hope, though, that maybe the one or the other reader might pick up a point or too, or at least start thinking about it in a different way, as it would surely make their life easier... :) When I was at University, many moons ago, they taught us the concept of a Dykstra Diagram - basically any block should have only one entrance and one exit. I adhere to that ideology all my career-life. And it has saved me from many bugs like the one Marco pointed out. These things are sooooo hard to find, as sometimes stuff works, and sometimes it doesn't... So, my recommendation is to use IF THEN ELSE blocks, and always make things go through the whole block until the very end. If it is conditional, place it in a THEN or ELSE block... Also, being a nitpicking virgo, I choose to always comment my END statements - that way I can easily see where one block ends and where the next. And, together with careful indentation, I easily see if there's an end too much or too little, and where. Again, saved me from many bugs. Or, the other way around, found many bugs in others code due to not adhering to these simple best practices... I'd start the loop like this: for each ap-ledger no-lock where ap-ledger.company = "ffi" and ap-ledger.bank-acc = "99" and ap-ledger.trans-date = 05/26/2016 break by ap-ledger.vend-num : if last-of(ap-ledger.vend-num) then do: /* last-of vend-num */ if asd-count > 0 then final-amount = tmp-amount. else final-amount = ap-ledger.amount. final-amount = 0. asd-count = 0. end. /* last-of vend-num */ end. /* for each ap-ledger no-lock */ Placing WHERE, AND and OR underneath each other, it becomes clear what the conditions structure is, and it is easy to put another line in, or take one out. Placing the THEN into the same column as the ELSE makes it easier to associate the ones that belong together.

Continue reading...
 
Status
Not open for further replies.
Back
Top