Solved

how do i check if there is no filename?

Posted on 1998-02-13
2
153 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
[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
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

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

Suggested Solutions

Title # Comments Views Activity
Press three keys together and trigger a function 3 76
Delphi...Split view - idea? 1 147
Wincontrol not (correctly) drawn 15 59
TAction.OnAfterExecute? 2 32
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…

751 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