Solved

Create a File Exact Syntax

Posted on 2001-08-22
6
175 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
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!

 
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

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!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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