Forum > General
GetEnV Error
captian jaster:
--- Quote from: eny on April 02, 2010, 08:50:08 pm ---Never copy & paste code and hope that it does what you want :D
Why don't you use the more self-explanatory functions?
Like this...
--- Code: ---procedure CheckAndCreateDir(const pName: string);
begin
if not DirectoryExists(pName) then
begin
writeln(format('Missing directory: "%s"', [pName]));
writeln('Making directory...');
Delay(200);
CreateDir(pName);
end;
end;
procedure GetFolders;
begin
writeln('Getting Folders...');
Delay(1000);
CheckAndCreateDir('System');
CheckAndCreateDir('Others');
writeln('All Directories Found!');
end;
--- End code ---
--- End quote ---
Thats a cool code.... i can understand it easy to..
But ive never heard of DirectoryExist code.. isit in the Dos unit?
Edit:Never mind its in sysutils... What eles can GetEnV Do? And whats the point of format?
I was using GetEnV cuz i didnt know about DirectoryExists
I tryed it and it worked but arent you suppose to use Function instead of procedure
eny:
--- Quote from: captian jaster on April 02, 2010, 10:05:02 pm ---Thats a cool code.... i can understand it easy to..
--- End quote ---
Great; that was the intention :D
--- Quote ---But ive never heard of DirectoryExist code.. isit in the Dos unit?
--- End quote ---
Have a look at the docs; great reference material (DirectoryExists is in the rtl manual; same as GetEnv).
--- Quote ---And whats the point of format?
--- End quote ---
The format function is great for building complex strings with minimal effort.
--- Quote ---I tryed it and it worked but arent you suppose to use Function instead of procedure
--- End quote ---
If you want some sort of result back, then use a function.
As in this case a procedure gets the job done.
marcov:
One shouldn't use unit dos to begin with. Uses sysutils.
captian jaster:
Whats Wrong With the dos unit?................... wait i dont need it
Navigation
[0] Message Index
[*] Previous page