Brad.G
June 12th, 2006, 06:17 AM
im learning loops and i just have a couple of questions so im perfectly clear on whats going on.
ive read a tutorial on for, while & do, and i figured the best type of loop to use to count the amount of files in a folder would be do, as it checks the condition at the end
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int a = 0;
AnsiString filepath;
filepath = "\\\\server\\FMRS\\QC\\12-13\\*.*";
TSearchRec sr;
int iAttributes = 0;
if (FindFirst(filepath,iAttributes,sr)== 0);
{
do
{
a++;
Edit1->Text = a;
}
while (FindNext(sr)== 0);
}
}
now i understand whats going on above apart from
== 0
what exactly is this for? i know that == 0 means to set it as 0 , but what is it setting to 0? just playing around i removed the ==0 to see what happens.. not suprisingly it copiled, but did not give the correct results.
also, by adding
iAttributes |= faAnyFile ;
to the above will search for any file type , may they be hidden etc etc
but iattributes, i declared as a variable above .. so why am i putting |= faNyFile; afterwards .... variables only take numbers, so is faAnyFile giving it a value?
ive read a tutorial on for, while & do, and i figured the best type of loop to use to count the amount of files in a folder would be do, as it checks the condition at the end
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int a = 0;
AnsiString filepath;
filepath = "\\\\server\\FMRS\\QC\\12-13\\*.*";
TSearchRec sr;
int iAttributes = 0;
if (FindFirst(filepath,iAttributes,sr)== 0);
{
do
{
a++;
Edit1->Text = a;
}
while (FindNext(sr)== 0);
}
}
now i understand whats going on above apart from
== 0
what exactly is this for? i know that == 0 means to set it as 0 , but what is it setting to 0? just playing around i removed the ==0 to see what happens.. not suprisingly it copiled, but did not give the correct results.
also, by adding
iAttributes |= faAnyFile ;
to the above will search for any file type , may they be hidden etc etc
but iattributes, i declared as a variable above .. so why am i putting |= faNyFile; afterwards .... variables only take numbers, so is faAnyFile giving it a value?