Here are handy macro definitions that will emulate FoxPro type commands and structures:

//----------------------------------------------------------------
#define ScanFor(Cond, Table) Table->First(); while(!Table->Eof){if(Cond){
#define EndScanFor(Table) }Table->Next();}

#define ScanWhile(Cond, Table) Table->First(); while(Cond){
#define EndScanWhile(Table) Table->Next();}
// ScanWhile requires you to position to best starting record - with Seek(), or just First()

#define CountForTo(Cond, CountVar, Table) CountVar=0;Table->First();while(!Table->Eof){if(Cond)CountVar++; Table->Next();}
//integer CountVar needs to be created before using CountForTo()

#define SumTo(FieldName, SumVar, Table) SumVar=0.0;Table->First();while(!Table->Eof){SumVar=SumVar+Table->FieldValues[FieldName];Table->Next();}

#define SumForTo(FieldName, Cond, SumVar, Table) SumVar=0.0;Table->First();while(!Table->Eof){if(Cond)SumVar=SumVar+Table->FieldValues[FieldName];Table->Next();}
//double SumVar needs to be created before using SumForTo()
//----------------------------------------------------------------


After you make these definitions at top of your unit you can use them
anywhere in the same unit.

Here is an example how to use ScanFor() macro on a TTable with name = Customer
The routine below shows a message for all customers in Arizona with a
non-zero balance.

ScanFor(Customer->FieldValues["State"] = "AZ" && Customer->FieldValues["Balance"] > 0.0, Customer);
  ShowMessage(Customer->FieldValues["Name"] + " still owes you $" + FloatToStr(Customer->FieldValues["Balance"]));
  ... other statements here ...
EndScanFor(Customer);

Check for more handy BC++B hints frequently.

Abri Technologies
www.abri.com