Question

i need some help with my procedure. I want to save some strings in a stringlist which is created in another procedure. How can i do this?

I wrote a comment at the right place to understand it better.

procedure GetIniNamesWithoutExt(IniPfade: TStringList);
var
  i, suchPunkt: integer;
  ini: TIniFile;
  Modul, fullFileName, IniName: String;
begin
  try
  for i := 0 to IniPfade.Count-1 do
  begin
    fullFileName := IniPfade.Strings[i];
    Modul := ExtractFileName(fullFileName);  // Dateiname aktueller Ini + .Ini Endung
    suchPunkt := Pos('.', Modul);
    IniName := Copy(Modul, 1, suchPunkt-1);  // Aktueller Modulname ohne ini Endung
    // Here should be the Code for saving the String "IniName" to a StringList which is created in procedure a. Procedure a calls the procedure GetIniNamesWithoutExt.
  end;
  finally

  end;
end;
Was it helpful?

Solution

How about

procedure GetIniNamesWithoutExt(IniPfade, Module: TStrings);
var
  i, suchPunkt: integer;
  ini: TIniFile;
  Modul, fullFileName, IniName: String;
begin
  Module.BeginUpdate;
  try
    for i := 0 to IniPfade.Count-1 do
    begin
      fullFileName := IniPfade.Strings[i];
      Modul := ExtractFileName(fullFileName);  // Dateiname aktueller Ini + .Ini Endung
      suchPunkt := Pos('.', Modul);
      IniName := Copy(Modul, 1, suchPunkt-1);  // Aktueller Modulname ohne ini Endung
      Module.Add(IniName);
    end;
  finally
    Module.EndUpdate;
  end;   
end;

and from procedure A:

procedure A;
var 
  Module: TStringList;
begin
  Module := TStringList.Create;
  try
    GetIniNamesWithoutExt(IniPfade , Module);
    // Do Whatever you want with "Module"
  finally
    Module.Free;
  end;
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top