delphi - Delphi7, Save User's Changes or other User's Information / Notes -


in program, user completes form , presses submit. then, textfile or random extension file created, in user's information written. so, whenever user runs application form, check if file, has information, exists, copies information , pastes form. however, not working reason (no syntax errors):

procedure tform1.formcreate(sender: tobject); var   filedest: string;   f: textfile;   info: array[1..12] of string; begin   filedest := extractfilepath(paramstr(0)) + 'user\identity\identityofmyself.txt';    if fileexists(filedest)   begin     assignfile(f,filedest);     reset(f);      readln(info[1], info[2], info[3], info[4], info[5], info[6], info[7],       info[8], info[9], info[10], info[11], info[12]);           edit1.text := info[1];     edit2.text := info[2];     combobox1.text := info[3];                 combobox5.text := info[4];     combobox8.text := info[4];     combobox6.text := info[5];     combobox7.text := info[6];     edit3.text := info[7];     edit4.text := info[8];     edit5.text := info[11];     edit6.text := info[12];     combobox9.text := info[9];     combobox10.text := info[10];           closefile(f);                                              end   else   begin     showmessage('file not found');   end;  end; 

the file exists, shows message file not found. don't understand.

i took liberty of formatting code you. see difference (before, after)? also, if you, name controls better. instead of edit1, edit2, edit3 etc. use efirstname, elastname, eemailaddr, etc. otherwise become pita maintain code, , confuse e.g. combobox7 combobox4.

one concrete problem code line:

readln(info[1], info[2], info[3], info[4], info[5], info[6], info[7],   info[8], info[9], info[10], info[11], info[12]);   

you forgot specify file f!

also, before formatted code, final end of procedure missing. maybe blocks incorrect in actual code, showmessage displayed if file exists? (yet reason format code properly...)

if encountered problem , wanted quick debugging, i'd insert

showmessage(booltostr(fileexists(filedest), true)); exit; 

just after line

filedest := ... 

just see returned value of fileexists(filedest) is. (of course, set breakpoint , use debugger.)

if false, wonder in world filedest contains: well, replace 'debugging code' above one:

showmessage(filedest); exit; 

then use windows explorer (or better yet: command prompt) see if file there or not.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -