Forum > General

My ReturnDirContents Code.. need your help on this one guys...

(1/2) > >>

captian jaster:
I need help on Fixing he errors i get in this.
Heres the Record:

--- Code: ---TRDirConREC = Record
 Count:LongInt;
 Info:TSearchREC;
 AllowWrite,FoundFiles:Boolean;
 WriteInfo,WriteCount:String;
 end;

--- End code ---

Main Procedure:

--- Code: ---Procedure ReturnDirContents;
BEGIN
  With RDirCon Do
   begin
     Count:=0;
     IF FindFirst('*',FAanyFile,FADirectory)=0Then
     begin
       Repeat
       INC(Count);
        With Info Do
        begin
          WriteInfo := Name:40,Size:15;
          IF(Attr AND FADirectory)= FADirectory Then
          IF(AllowWrite = True)Then
          Write('Dir:');
          Writeln(Name:40,Size:15);
        end;
       Until(FindNext(Info)<>0);
     end;
     FindClose(Info);
     WriteCount := Count;
     IF(Count <>0)Then FoundFiles := True Else FoundFiles := False;
     IF(AllowWrite = True)Then Writeln('Number Of Content in Folder:',WriteCount);
   end;
END;

--- End code ---

Errors I get:

--- Quote ---FFU.pas(53,44) Error: Call by var for arg no. 3 has to match exactly: Got "ShortInt" expected "TSearchRec"
Hint: Found declaration: FindFirst(const AnsiString, LongInt,out TSearchRec):LongInt;
FFU.pas(59,28) Fatal: Syntax error, ";" expected but ":" found

--- End quote ---
Help!

Zoran:

--- Quote ---FFU.pas(53,44) Error: Call by var for arg no. 3 has to match exactly: Got "ShortInt" expected "TSearchRec"
Hint: Found declaration: FindFirst(const AnsiString, LongInt,out TSearchRec):LongInt;

--- End quote ---

So, this line is wrong:

--- Code: ---     IF FindFirst('*',FAanyFile,FADirectory)=0Then

--- End code ---

it should probably be:

--- Code: ---     IF FindFirst('*', FAanyFile or FADirectory, info)=0 Then

--- End code ---



--- Quote ---FFU.pas(59,28) Fatal: Syntax error, ";" expected but ":" found

--- End quote ---
Look at this line:

--- Code: ---          WriteInfo := Name:40,Size:15;

--- End code ---
You declared WriteInfo as string, so on the right side of assignment, you must provide a string. This should probably be (enclosed in quotes):

--- Code: ---          WriteInfo := 'Name:40,Size:15';

--- End code ---

captian jaster:

--- Quote from: Zoran on April 26, 2010, 07:12:13 pm ---
--- Quote ---FFU.pas(53,44) Error: Call by var for arg no. 3 has to match exactly: Got "ShortInt" expected "TSearchRec"
Hint: Found declaration: FindFirst(const AnsiString, LongInt,out TSearchRec):LongInt;

--- End quote ---

So, this line is wrong:

--- Code: ---     IF FindFirst('*',FAanyFile,FADirectory)=0Then

--- End code ---

it should probably be:

--- Code: ---     IF FindFirst('*', FAanyFile or FADirectory, info)=0 Then

--- End code ---



--- Quote ---FFU.pas(59,28) Fatal: Syntax error, ";" expected but ":" found

--- End quote ---
Look at this line:

--- Code: ---          WriteInfo := Name:40,Size:15;

--- End code ---
You declared WriteInfo as string, so on the right side of assignment, you must provide a string. This should probably be (enclosed in quotes):

--- Code: ---          WriteInfo := 'Name:40,Size:15';

--- End code ---

--- End quote ---

WriteInfo is wrong. i know that, i just dont know what kinda of variable to set it to. Its not that im writing Name:40,Size:15
into the console. im trying to work with the FindClose Name And Size Vars... This Is Difficult... Heres What i worked off of..
http://www.freepascal.org/docs-html/rtl/sysutils/findfirst.html

That and i still get the some errors on compile... Its Not this thats wrong:
--- Code: --- IF FindFirst('*',FAanyFile,FADirectory)=0Then
--- End code ---
Its That it expected some thing from the Info TSearchREC; and i cant fix it. I Suspect its Cuz of my First With Declaration. got the compiler confused..
BART! Get TO IT!

Zoran:

--- Quote from: captian jaster on April 26, 2010, 07:22:59 pm ---WriteInfo is wrong. i know that, i just dont know what kinda of variable to set it to.

--- End quote ---

Okay, surely I can't know that either... can I?


--- Quote from: captian jaster on April 26, 2010, 07:22:59 pm ---Its Not this thats wrong:
--- Code: --- IF FindFirst('*',FAanyFile,FADirectory)=0Then
--- End code ---
Its That it expected some thing from the Info TSearchREC; and i cant fix it.

--- End quote ---

I say it is.


--- Quote from: captian jaster on April 26, 2010, 07:22:59 pm ---I Suspect its Cuz of my First With Declaration. got the compiler confused..

--- End quote ---

You can try uncofusing the compiler by removing "with" and putting the prefix "RDirCon." everywhere where needed. I say it will still be confused.

Then you can try what I suggested.
Or wait for Bart.

captian jaster:
Dood. i did change the

--- Code: --- IF FindFirst('*',FAanyFile,FADirectory)=0Then
--- End code ---
to the way you said.. the same error came up....
If any one can help... What kind of variable can i set write info to?

Navigation

[0] Message Index

[#] Next page

Go to full version