Recent

Author Topic: SelectDirectoryDialog  (Read 5662 times)

Zath

  • Sr. Member
  • ****
  • Posts: 391
SelectDirectoryDialog
« on: September 02, 2015, 09:32:12 pm »
If my prog can't find the ini file, you get the option to choose the directory and it then writes a new ini file.
What's the best way to read the new ini file ?
Do I have a line to read immediately after saving or do I put a line to read the ini file in the dialog close event ?
On asking this question,  I'm wondering if it should be .FileName when I just want the directory ?
 
Any guidance welcome.

Code: [Select]
procedure TForm1.Button4Click(Sender: TObject);
begin
  if SelectDirectoryDialog1.Execute then begin
    drName := SelectDirectoryDialog1.FileName;
    edit1.text:=drName;
    savetoini('D:\RubyEditor.ini');
    //readfromini('D:\RubyEditor.ini');
  end;
end;   

added
It works putting it in the dialog close event but is that correct ?

I'm using 1.42 / 264 on Win 7 /64
« Last Edit: September 02, 2015, 09:36:09 pm by Zath »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: SelectDirectoryDialog
« Reply #1 on: September 03, 2015, 01:01:29 am »
1) Doesn't savetoini save the existing settings to the ini? If yes then reading back the values shouldn't change a thing it will only waste time.
2) why would you allow the end to dictate something as basic as the ini location? How do you know where to look the next time the application starts?

There are 2 general accepted location for an ini file, in the application's directory or in the OS's assigned folders ee home in linux and users\Username\AppData in windows. looking in two locations is a no brainer searching all over the hard disk to find your ini file is a bit over the top. I assume ofcourse that you want to have your application registry free.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Zath

  • Sr. Member
  • ****
  • Posts: 391
Re: SelectDirectoryDialog
« Reply #2 on: September 03, 2015, 02:07:50 am »
On initial use, the user needs to locate his game server files on his pc. This location is stored in the ini.
The files could be on any drive and the directory name could be unique to the user.
Subsequent use, the prog reads the ini and goes straight to the required directory.

Yes the savetoini did save. I have menu options that were disabled until a valid directory was chosen. I wanted the valid location to be live after the savetoini and enable the menu options.
Wherever I tried to test the condition to enable the menus, I couldn't get it to work.

I made the buttons permanently enabled for now.

 

TinyPortal © 2005-2018