Solved

Create a File Exact Syntax

Posted on 2001-08-22
6
174 Views
Last Modified: 2010-04-06
Hello i want the Exact Syntax as if you were doing this yourself

Create a File called   abc.dat in C:\
so the path is  C:\abc.dat

ok i want to push a button and the file has been created
the file is empty no data just a blank file...

thanks in advance neopolis
i am new at delphi so i need exact code...
0
Comment
Question by:neopolis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 10

Expert Comment

by:Jacco
ID: 6414579
Hi there,

procedure CreateFile(const aFileName: string);
var
  F: TextFile;
begin
  AssignFile(F, aFileName);
  Rewrite(F);
  CloseFile(F);
end;

Regards Jacco
0
 

Author Comment

by:neopolis
ID: 6414697
i cant get it to write the abc.dat file can you create it in Delphi the copy the source code and paste it here
so i can see where the File name and Path go thanks
0
 
LVL 6

Expert Comment

by:edey
ID: 6414873
Ummmmm, take the above procedure & call it like so:

createFile('C:\abc.dat');

simple enough, no? Parameter passing is a _very_ basic element of any language, I would think that you'd be well served by a couple of hours reading your manual.

GL
Mike
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
VSF earned 10 total points
ID: 6414899
Here is the complete usage of the code!
Hope it helps!
VSF
www.victory.hpg.com.br

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure CreateFile(const aFileName: string);
var
 F: TextFile;
begin
 AssignFile(F, aFileName);
 Rewrite(F);
 CloseFile(F);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 CreateFile('c:\abc.dat');
end;

end.
0
 

Author Comment

by:neopolis
ID: 6415092
thanks this works for me
0
 
LVL 3

Expert Comment

by:VSF
ID: 6418504
I'm glad I could help!

VSF
UIN: 14016999

Please show your support by visiting my homepage:
www.victory.hpg.com.br
www.enge.cjb.net
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 77
Convert MS Word document to a PDF file 9 133
Delphi: making a BW image transparent 10 136
Delphi Seattle StructureView color 1 33
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question