From bbb15f0d0ec59d0c115f66f17d12687d45b00d58 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 29 Oct 2020 22:29:11 +0000 Subject: [PATCH] LazStats: Rename LazStats.ini to LazStats.hlp. Update ContextHelpUnit. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7828 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../lazstats/{LazStats.ini => LazStats.hlp} | 0 .../source/forms/misc/contexthelpunit.lfm | 2 +- .../source/forms/misc/contexthelpunit.pas | 38 ++++++++++--------- 3 files changed, 22 insertions(+), 18 deletions(-) rename applications/lazstats/{LazStats.ini => LazStats.hlp} (100%) diff --git a/applications/lazstats/LazStats.ini b/applications/lazstats/LazStats.hlp similarity index 100% rename from applications/lazstats/LazStats.ini rename to applications/lazstats/LazStats.hlp diff --git a/applications/lazstats/source/forms/misc/contexthelpunit.lfm b/applications/lazstats/source/forms/misc/contexthelpunit.lfm index 51e212070..8d7927fbd 100644 --- a/applications/lazstats/source/forms/misc/contexthelpunit.lfm +++ b/applications/lazstats/source/forms/misc/contexthelpunit.lfm @@ -38,7 +38,7 @@ object ContextHelpForm: TContextHelpForm TabOrder = 0 end end - object Memo1: TMemo + object HelpMemo: TMemo AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner AnchorSideRight.Control = Owner diff --git a/applications/lazstats/source/forms/misc/contexthelpunit.pas b/applications/lazstats/source/forms/misc/contexthelpunit.pas index 7c81dd0ed..d3b2b321d 100644 --- a/applications/lazstats/source/forms/misc/contexthelpunit.pas +++ b/applications/lazstats/source/forms/misc/contexthelpunit.pas @@ -6,7 +6,7 @@ unit ContextHelpUnit; interface uses - IniFiles, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, + IniFiles, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls; type @@ -15,14 +15,12 @@ type TContextHelpForm = class(TForm) Button1: TButton; - Memo1: TMemo; + HelpMemo: TMemo; Panel1: TPanel; procedure Button1Click(Sender: TObject); private - { private declarations } public - { public declarations } - procedure HelpMessage(lTag: integer); + procedure HelpMessage(ATag: integer); end; var @@ -32,39 +30,45 @@ implementation {$R *.lfm} -function ReadIniFileTag(var lTag: Integer): string; -//Read string with index lTag +// Read string with index ATag +function ReadHlpFileTag(var ATag: Integer): string; var lIniFile: TIniFile; - lFileName,lLang: string; + lFileName, lLang: string; begin - lFilename := ChangeFileExt(ParamStr(0), '.ini'); - if (not FileExists(lFilename)) then begin - Result := 'No contextual help: unable to find '+lFilename; + lFilename := ChangeFileExt(ParamStr(0), '.hlp'); + + if not FileExists(lFilename) then begin + Result := 'No context help: unable to find helo file "' + lFilename + '"'; exit; end; - Result := 'No contextual help found for '+IntToStr(lTag); + lIniFile := TIniFile.Create(lFilename); try lLang := lIniFile.ReadString('LANGUAGE', 'DEFAULT', ''); - Result := lIniFile.ReadString(lLang, IntToStr(lTag), Result); - Result := StringReplace(Result, '\n', LineEnding, [rfIgnoreCase, rfReplaceAll]); + Result := lIniFile.ReadString(lLang, IntToStr(ATag), Result); + if Result <> '' then + Result := StringReplace(Result, '\n', LineEnding, [rfIgnoreCase, rfReplaceAll]) + else + Result := 'No context help found for ' + IntToStr(ATag); finally lIniFile.Free; end; end; + procedure TContextHelpForm.Button1Click(Sender: TObject); begin Close; end; -procedure TContextHelpForm.HelpMessage(lTag: integer); + +procedure TContextHelpForm.HelpMessage(ATag: integer); begin - Memo1.Lines.Clear; - Memo1.Lines.Text := ReadIniFileTag(lTag); + HelpMemo.Lines.Text := ReadHlpFileTag(ATag); Show; end; + end.