Solved

how do i check if there is no filename?

Posted on 1998-02-13
2
150 Views
Last Modified: 2010-04-04
how do i check if there is no filename entered in the
open file dialog and the user just press the cancel button
in the open file dialog?
procedure TEditForm.Open(const FileName: string);
begin
 PathName := FileName;
 Editor.Lines.LoadFromFile(PathName);
 Editor.SelStart := 0; <- error here when the user presses the cancel button in open file dialog...

 Caption := ExtractFileName(PathName);
 Editor.Modified := False;
end;
0
Comment
Question by:superboy
2 Comments
 

Accepted Solution

by:
puppy earned 10 total points
ID: 1359184
hi superboy,
try this:
procedure TForm1.Button1Click(Sender: TObject);
label ok,nofile;
begin
OpenDialog1.execute;
if opendialog1.filename = '' then goto nofile
else goto ok;
ok:
editor.lines.loadfromfile(opendialog1.filename);
...
nofile:
end;
0
 

Author Comment

by:superboy
ID: 1359185
i solved this problem already..i set a boolean flag to true when opening a file and this affects the canel button..the boolean flag is fileopened..thanx anyway..
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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

790 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