unit mFNAGBase;
interface
uses
IniFiles, SysUtils, Classes, Dialogs;
type
TFNAGBasicControl =
class(TObject)
private
{}
public
UsedLanguageFilePath:
String;
//Damit das File problemlos wieder geöffnet werden kann
LanguageFiles:
Array of TIniFile;
//Ist jetzt in TFNAGBasicControl
procedure ReadAllIn;
procedure OpenFile(LanguageName:
string);
procedure FreeUsed;
procedure FreeUnused;
function ReadEntry(Entry:
string):
string;
end;
var
FNAGBasicControl: TFNAGBas
#icControl;
implementation
procedure TFNAGBasicControl.ReadAllIn;
var
SR: TSearchRec;
x: integer;
begin
x := 0;
if FindFirst(ExtractFilePath(ParamStr(0)) + '
Language\*.ini', faAnyFile, SR) = 0
then
begin
repeat
if (SR.Attr <> faDirectory)
then
begin
inc(x);
SetLength(FNAGBasicControl.LanguageFiles, x + 1);
//An dieser Stelle gibt es merkwürdiger weise eine AccessViolation mit Abbruch
FNAGBasicControl.LanguageFiles[x] := TIniFile.Create(ExtractFilePath(ParamStr(0)) + '
Language\' + sr.
Name);
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;
procedure TFNAGBasicControl.OpenFile(LanguageName:
string);
var
x: integer;
begin
x := 0;
for x := 1
to high(FNAGBasicControl.LanguageFiles)
do
begin
if ExtractFileName(FNAGBasicControl.LanguageFiles[x].FileName) = LanguageName + '
.ini'
then
begin
FNAGBasicControl.LanguageFiles[0] := LanguageFiles[x];
FNAGBasicControl.UsedLanguageFilePath := FNAGBasicControl.LanguageFiles[0].FileName;
end;
end;
end;
procedure TFNAGBasicControl.FreeUsed;
begin
FNAGBasicControl.LanguageFiles[0].Free;
end;
procedure TFNAGBasicControl.FreeUnused;
var
x: integer;
begin
x := 0;
for x := 1
to high(FNAGBasicControl.LanguageFiles)
do
FNAGBasicControl.LanguageFiles[x].Free;
SetLength(FNAGBasicControl.LanguageFiles, 1);
end;
function TFNAGBasicControl.ReadEntry(Entry:
string):
String;
begin
If FNAGBasicControl.LanguageFiles[0] <>
nil then
Result := FNAGBasicControl.LanguageFiles[0].ReadString('
words', Entry, '
missing')
// hier gab es bisher immer eine Accessviolation
Else if FNAGBasicControl.LanguageFiles[0] =
nil then
ShowMessage('
No Languagefile opened.');
end;
end.