Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I creat a directory...

Status
Not open for further replies.

KeeperOfTheGood

Technical User
May 7, 2005
3
CA
Hey oh

Ok, I hope someone here can help. Searches and the like haven't. This question has to have been asked befor! Links or a direct answer, either would be greatly appreciated.

I am running a program called Apophysis, from It is a fractal creating program written in Delphi and allows script writting in Delphi.

I need to be able to creat directories. I have found the command for deleting directories, but not one for making them.

Following is a script that comes with the program, given here to exemplefy. The criticle line in it is Renderer.Filename :='c:\renders\' + Flame.Name + '.png'; If the directory does not already exist, the script hangs. I want to mod this to first either query the user or use the flame name to creat a directry before saving to that directory. To query or to creat a string with a name isn't any good when I don't know the code to make the directory.

Thank you in advance.

{ Renders all of the flames in a
selected parameter file to disk.
Set the render settings to taste }
Renderer.Width := 320;
Renderer.Height := 240;
{ Comment out the following line to
render the currently loaded file }
SetFlameFile(GetFilename);
for i := 0 to FileCount do
begin
LoadFlame(i);
Flame.SampleDensity := 10;
Flame.Oversample := 2;
Flame.FilterRadius := 0.4;
{ Change the folder and extension if neccessary }
Renderer.Filename :='c:\renders\' + Flame.Name + '.png';
SetRenderBounds;
Render;
end;
UpdateFlame := False;
 
Hi,

if you have Delphi 6 or higher you can use the ForceDirectories function. it will create a full directory structure for you. small example :
ForceDirectories('c:\a\b\c');
This will create a directory called a with a subdir b and c as subdir for b.
to check if a directory exists use the DirectoryExists function...

Code:
{ Renders all of the flames in a
  selected parameter file to disk.
  Set the render settings to taste }
Renderer.Width := 320;
Renderer.Height := 240;
{ Comment out the following line to
  render the currently loaded file }
[b]ForceDirectories('c:\renders\');[/b]
SetFlameFile(GetFilename);
for i := 0 to FileCount do
begin
  LoadFlame(i);
  Flame.SampleDensity := 10;
  Flame.Oversample := 2;
  Flame.FilterRadius := 0.4;
  { Change the folder and extension if neccessary }
  Renderer.Filename :='c:\renders\' + Flame.Name + '.png';
  SetRenderBounds;
  Render;
end;
UpdateFlame := False;

small tip when posting code, use TGML tags. like this :
[ignore]
Code:
your Delphi code
[/ignore]

--------------------------------------
What You See Is What You Get
 
Hey oh

Thank you very much. I will use that tag in the future. Unfortunatly it appears that this code line does not work. I get the message
Unknown method or routine: 'ForceDirectories'
From this I will need to assume that it is not written in that level of Delphi or that this codeline isn't active in the edit window.

I gather that there are no other options for creating directories then?

Keeps
 
Have you looked at the CreateDir function?

Andrew
Hampshire, UK
 
Hey oh

Thank you.

Ok, I tried that, and it works! :) Thankyou indeed. Funny that a google didn't return to me a result for that as a Delphi command. Anyway, it seems to only creat a single level directory, and no subdirectories. Is that a limitation I should expect of this command? Or are there other parrameters?

Code:
CreateDir ('c:\keeps');
 
you must include the sysutils unit.
if you don't know something about a particular function set the cursor on it and hit F1, Delphi help will reveal from what unit this function is from...

--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top