WITH DO - SKIP record?

KisuKisu Member Posts: 381
If I have a long WITH DO STATEMENT like

WITH x DO BEGIN
y; // something code start
y;
y;
y;
y;
y; // something code end
END;

How would I skip records if I have boolean global variable on table record x?

Do a IF statement for it
IF x.boolvar THEN //(true)
y;
y;
ELSE
MESSAGE('bla bla %1',...);

or is there a skip for it?
K.S.

Answers

  • KYDutchieKYDutchie Member Posts: 345
    Kisu,

    If X is your dataitem, you could skip the records in your filter where you retrieve the record for x. You could set: x.Setrange(boolvar, TRUE); then only records with the boolean set will be retrieved.

    If it is not the DataItem but a record you retrieve based on another dataitem, you could put an if x.boolvar = FALSE THEN exit; immediately after you retrieve the record.

    Hope this makes sence and helps you,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • KisuKisu Member Posts: 381
    Doh was thinkin too hard. :D
    That was simple and working sollution ^^
    K.S.
  • DenSterDenSter Member Posts: 8,305
    Something to think about: I don't like WITH, it always confuses me. Especially when the code that affects the variable in the WITH spreads over more than a page, it is very easy to lose sight of wich variable you're dealing with. I always like to explicitly name the variable. It's more code, but it is a lot more readable to me. Besides, it actually works faster because you don't have to delete the variable name :mrgreen:
  • KisuKisu Member Posts: 381
    The with thingy is base code :p
    K.S.
  • DenSterDenSter Member Posts: 8,305
    I still don't like it :mrgreen:
  • krikikriki Member, Moderator Posts: 9,110
    DenSter wrote:
    Something to think about: I don't like WITH, it always confuses me. Especially when the code that affects the variable in the WITH spreads over more than a page, it is very easy to lose sight of wich variable you're dealing with. I always like to explicitly name the variable. It's more code, but it is a lot more readable to me. Besides, it actually works faster because you don't have to delete the variable name :mrgreen:
    I completely agree on this!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.