From 046838f1cea10b5722cc2f091d8e3ccd7f158150 Mon Sep 17 00:00:00 2001 From: lazarus-bart Date: Mon, 6 Jan 2020 09:37:40 +0000 Subject: [PATCH] Sudoku: move DbgS() functions to the unit where the types concerned are defined. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7244 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/sudoku/scratchpad.pas | 22 ---------------------- applications/sudoku/sudoku.lpi | 1 + applications/sudoku/sudokutype.pas | 25 +++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/applications/sudoku/scratchpad.pas b/applications/sudoku/scratchpad.pas index 13a80c61d..002432b7a 100644 --- a/applications/sudoku/scratchpad.pas +++ b/applications/sudoku/scratchpad.pas @@ -38,28 +38,6 @@ implementation {$R *.lfm} -function DbgS( ASet: TDigitSet): String; overload; -var - D: TDigits; -begin - Result := '['; - for D in ASet do - begin - Result := Result + IntToStr(D) + ','; - end; - if (Result[Length(Result)] = ',') then System.Delete(Result, Length(Result), 1); - Result := Result + ']'; -end; - -function DbgS(ASquare: TSquare): String; overload; -const - BoolStr: Array[Boolean] of String = ('False','True'); -begin - Result := '[Value: ' + IntToStr(ASquare.Value) + ', '; - Result := Result + 'Locked: ' + BoolStr[ASquare.Locked] + ', '; - Result := Result + 'DigitsPossible: ' + DbgS(ASquare.DigitsPossible) + ']'; -end; - { TScratchForm } procedure TScratchForm.FormActivate(Sender: TObject); diff --git a/applications/sudoku/sudoku.lpi b/applications/sudoku/sudoku.lpi index 4731faa6c..c042e12c4 100644 --- a/applications/sudoku/sudoku.lpi +++ b/applications/sudoku/sudoku.lpi @@ -81,6 +81,7 @@ + diff --git a/applications/sudoku/sudokutype.pas b/applications/sudoku/sudokutype.pas index b7589b289..70e0f63d4 100644 --- a/applications/sudoku/sudokutype.pas +++ b/applications/sudoku/sudokutype.pas @@ -56,12 +56,37 @@ type //function Solved: Boolean; end; +function DbgS(ASet: TDigitSet): String; overload; +function DbgS(ASquare: TSquare): String; overload; + implementation const cmin : Array[1..9] of Integer = (1, 1, 1, 4, 4, 4, 7, 7, 7); cmax : Array[1..9] of Integer = (3, 3, 3, 6, 6, 6, 9, 9, 9); +function DbgS(ASet: TDigitSet): String; overload; +var + D: TDigits; +begin + Result := '['; + for D in ASet do + begin + Result := Result + IntToStr(D) + ','; + end; + if (Result[Length(Result)] = ',') then System.Delete(Result, Length(Result), 1); + Result := Result + ']'; +end; + +function DbgS(ASquare: TSquare): String; overload; +const + BoolStr: Array[Boolean] of String = ('False','True'); +begin + Result := '[Value: ' + IntToStr(ASquare.Value) + ', '; + Result := Result + 'Locked: ' + BoolStr[ASquare.Locked] + ', '; + Result := Result + 'DigitsPossible: ' + DbgS(ASquare.DigitsPossible) + ']'; +end; + { Counts the number of TDigitSet in ASet. aValue only has meaning if Result = 1 (which means this cell is solved)