Solved

Create a File Exact Syntax

Posted on 2001-08-22
6
166 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Deploying Delphi Application on Web Server 3 79
Delphi OLE Error 8 84
Delphi cmd execution 6 40
Find and Replace Stream with 0s 8 48
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now