Fastest way to check if the records are set

KisuKisu Member Posts: 381
Hey again

I'd need to find a solution to check if all table records boolean fields are checked and it should be fast function. :)

Is the fastest way to put FIND function to get any non checked fields or is there a faster way?
K.S.

Answers

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Just filter on FALSE and do an ISEMPTY.

    If there is a index on the field you can also use COUNT.
  • KisuKisu Member Posts: 381
    Just filter on FALSE and do an ISEMPTY.

    If there is a index on the field you can also use COUNT.

    Thanks :)
    K.S.
  • garakgarak Member Posts: 3,263
    but if you have more then 1 field, like 6 or more you must ever filter on the other fields like
    setrange(Field1,false);
    if not isempty then begin
      //here an loop if you need the recs
    end;
    setrange(Field1);
    setrange(Field2,false);
    if not isempty then begin
      //here an loop if you need the recs
    end;
    setrange(Field2);
    ....
    

    So an other way is to use the Field table in alliance with recref and fieldref.
    Fields.reset; //Field Table
    Fields.setrange(TableNo,27); //only Table Item
    Fields.setrange(Type,Fields.Type::Bool);
    Fields.setrange(Class,Fields.Class::Normal);
    if Fields.findset(false,false) then begin
      RecRef.OPEN(Fields.TableNo);
      repeat
        RecRef.findfirst; //or a special Rec with get(RecordID) or a loop with findset
        FieldsRef := RecRef.FIELD(Fields."No.");
        if Format(FieldsRef.VALUE) = 'Nein' then //'No'
          message('Feld %1 = %2',Fields.FieldName,FieldsRef.VALUE); //here you can also store the Recs in a temptable or print it out in a report
      until Fields.next = 0;
    end;
    

    Regards
    Do you make it right, it works too!
  • DenSterDenSter Member Posts: 8,305
    If you know you're going to loop, just use FINDSET right away. Using ISEMPTY is redundant in that case.
Sign In or Register to comment.