Inno Setup: Delete empty lines from test file -


we using below code delete empty lines text file, it's not working.

function updatepatchlogfileentries : boolean; var a_strtextfile : tarrayofstring; ilinecounter : integer;     conffile : string;  begin  conffile := expandconstant('{sd}\patch.log');     loadstringsfromfile(conffile, a_strtextfile);      ilinecounter := 0 getarraylength(a_strtextfile)-1     begin          if (pos('', a_strtextfile[ilinecounter]) > 0)              delete(a_strtextfile[ilinecounter],1,1);     end;      savestringstofile(conffile, a_strtextfile, false);               end; 

please me. in advance.

because re-indexing of array inefficient , having 2 arrays copying non empty lines of file unecessarily complicated, suggest use tstringlist class. has need wrapped inside. in code write function this:

[code] procedure deleteemptylines(const filename: string); var   i: integer;   lines: tstringlist; begin   // create instance of string list   lines := tstringlist.create;   try     // load file specified input parameter     lines.loadfromfile(filename);     // iterate line line bottom top (because of reindexing)     := lines.count - 1 downto 0     begin       // check if iterated line empty (after trimming       // text) , if so, delete       if trim(lines[i]) = ''         lines.delete(i);     end;     // save cleaned-up string list file     lines.savetofile(filename);       // free string list object instance     lines.free;   end; end; 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -