Solved

Create a File Exact Syntax

Posted on 2001-08-22
6
172 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
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
Independent Software Vendors: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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