Einzelnen Beitrag anzeigen

Benutzerbild von qb-tim
qb-tim

Registriert seit: 3. Mär 2006
Ort: Deutschland
280 Beiträge
 
Delphi 6 Professional
 
#1

Mein Sudoku Programm friert ein, komme nicht weiter

  Alt 30. Mai 2007, 15:33
Hi,

die folgende Prozedur soll aus s ein Sudoku machen. Folgendes ist vorab zu erwähnen:

=> ResetSudoku ist eine Prozedur, die das Programm zurücksetzt
=> c ist ein CHAR
=> x, y, i, j sind INTEGERs
=> s ist ein String
=> Edit[x, y] ist ein modifizierter TEdit (weitere PROPERTY "Sollution" (=Lösung) hinzugefügt)

Das Programm startet mit Form1 ohne Fehlermeldung. Sobald ich aber die Prozedur auslöse friert das Programm!
Die Decodierung sollte so funktionieren:

1. ASCII-Wert lesen
2. ASCII-Wert - 100 = ab
3. Trenne beide Ziffern
4. Setzte Ziffern in Edit[x, y] ein

Jedes ASCII-Zeichen steht für zwei Zahlen!

Delphi-Quellcode:
procedure TForm2.SetSudoku(s: String);
begin
  ResetSudoku;
  for i := 1 to 40 do
  begin
    c := s[i];
    y := Ord( c ) - 100;
    x := Round( Int( y / 10 ) );
    y := y - ( x * 10 );
    j := i * 2 - 1;
    Edit[Round( j - ( 9 * Int( j / 9 ) ) ), Round( Int( j / 9 ) )].Text := IntToStr(x);
    j := i * 2;
    Edit[Round( j - ( 9 * Int( j / 9 ) ) ), Round( Int( j / 9 ) )].Text := IntToStr(y);
  end;
  i := 41;
  c := s[i];
  y := Ord( c ) - 100;
  x := Round( Int( y / 10 ));
  y := y - ( x * 10 );
  j := i * 2 - 1;
  Edit[Round( j - ( 9 * Int( j / 9 ) ) ), Round( Int( j / 9 ) )].Text := IntToStr(x);
  for i := 42 to 81 do
  begin
    c := s[i];
    y := Ord( c ) - 100;
    x := Round( Int( y / 10 ) );
    y := y - ( x * 10 );
    j := i * 2 - 1;
    Edit[Round( j - ( 9 * Int( j / 9 ) ) ), Round( Int( j / 9 ) )].Sollution := IntToStr(x);
    j := i * 2;
    Edit[Round( j - ( 9 * Int( j / 9 ) ) ), Round( Int( j / 9 ) )].Sollution := IntToStr(y);
  end;
  i := 82;
  c := s[i];
  y := Ord( c ) - 100;
  x := Round( Int( y / 10 ));
  y := y - ( x * 10 );
  j := i * 2 - 1;
  Edit[Round( j - ( 9 * Int( j / 9 ) ) ), Round( Int( j / 9 ) )].Sollution := IntToStr(x);
  SollutionAvailable := True;
end;
  Mit Zitat antworten Zitat