| Autor |
Beitrag |
eruhenon
      
Beiträge: 53
|
Verfasst: Fr 13.04.07 00:12
Moin!
Ich schreib ja grade einen SGF-Reader. Nun hab ich die Oberfläche erstellt und es geschafft, dass wenn cih auf ein Feld klicke ein Stein erschient. Allerdings funktioniert dieses nur solange ich keine Datei geladen hab. Sobald ich eine SGF-Datei einlese erhalte ich eine Fehlermeldung, dass auf die Datei kein Zugriff möglich sei.
Darstellung auf dem Board:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41:
| procedure TForm1.placestone(i:integer;j:integer);
Begin
if (player) and (j=0) and (i<>0) and (i<>18) then tarray[i,j].picture.loadfromfile('LeWaB.bmp') else if (player) and (j=0) and (i=0) then tarray[i,j].picture.loadfromfile('TLCB.bmp') else if (player) and (j=0) and (i=18) then tarray[i,j].picture.loadfromfile('BLCB.bmp') else if (player) and (j=18) and (i<>0) and (i<>18) then tarray[i,j].picture.loadfromfile('RWB.bmp') else if (player) and (j=18) and (i=0) then tarray[i,j].picture.loadfromfile('TRCB.bmp') else if (player) and (j=18) and (i=18) then tarray[i,j].picture.loadfromfile('BRCB.bmp') else if (player) and (i=0) and (j<>0) and (j<>18) and (i<>18) then tarray[i,j].picture.loadfromfile('ToWaB.bmp') else if (player) and (i=18) and (j<>0) and (j<>18) then tarray[i,j].picture.loadfromfile('BoWaB.bmp') else if (player) and (i<>0) and (i<>18) and (j<>0) and (j<>18) then tarray[i,j].picture.loadfromfile('MFB.bmp') else if (not player) and (j=0) and (i<>0) and (i<>18) then tarray[i,j].picture.loadfromfile('LeWaW.bmp') else if (not player) and (j=0) and (i=0) then tarray[i,j].picture.loadfromfile('TLCW.bmp') else if (not player) and (j=0) and (i=18) then tarray[i,j].picture.loadfromfile('BLCW.bmp') else if (not player) and (j=18) and (i<>0) and (i<>18) then tarray[i,j].picture.loadfromfile('RWW.bmp') else if (not player) and (j=18) and (i=0) then tarray[i,j].picture.loadfromfile('TRCW.bmp') else if (not player) and (j=18) and (i=18) then tarray[i,j].picture.loadfromfile('BRCW.bmp') else if (not player) and (i=0) and (j<>0) and (j<>18) and (i<>18) then tarray[i,j].picture.loadfromfile('ToWaW.bmp') else if (not player) and (i=18) and (j<>0) and (j<>18) then tarray[i,j].picture.loadfromfile('BoWaW.bmp') else if (not player) and (i<>0) and (i<>18) and (j<>0) and (j<>18) then tarray[i,j].picture.loadfromfile('MFW.bmp') end; |
Öffnen der Datei:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47:
| procedure TForm1.OpenSGF1Click(Sender: TObject); var sgffile : TextFile; buffer,gamefile,blacks,whites : string; p:integer; begin gamefile:=''; if form1.OpenDialog1.Execute then Begin AssignFile(sgffile,form1.OpenDialog1.FileName); Reset(sgffile) ; while not EOF(sgffile) do begin readln(sgffile,buffer); gamefile:=gamefile+buffer; end; CloseFile(sgffile); gamefile:=uppercase(gamefile);
p:=pos('PB[',gamefile); delete(gamefile,p,6); p:=pos('PW[',gamefile); delete(gamefile,p,6); p:=pos('B[',gamefile); blacks:=''; repeat blacks:=blacks+copy(gamefile,p+2,2)+#13; delete(gamefile,p,5); p:=pos('B[',gamefile); until p=0;
p:=pos('W[',gamefile); whites:=''; repeat whites:=whites+copy(gamefile,p+2,2)+#13; delete(gamefile,p,5); p:=pos('W[',gamefile); until p=0;
black.Text:=lowercase(blacks); white.Text:=lowercase(whites); end; end; |
Danke für die Hilfe!
|
|
Lannes
      
Beiträge: 2352
Erhaltene Danke: 4
Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
|
Verfasst: Fr 13.04.07 00:32
Hallo,
die SGF-Datei wird in Deinem Code über einem OpenDialog ausgewählt.
Dadurch wird eventuell das Arbeitsverzeichnis geändert und stimmt nicht mehr mit dem Verzeichnis überein das beim ersten Aufruf von placestone das aktuelle Arbeitsverzeichnis war.
Daraus folgert das Problem in Deinem Code:
Delphi-Quelltext 1: 2:
| if (player) and (j=0) and (i<>0) and (i<>18) then tarray[i,j].picture.loadfromfile('LeWaB.bmp') |
Hier fehlt der vollständige Pfad.
Arbeitsverzeichnis ist nicht immer identisch mit Anwendungsverzeichnis. 
_________________ MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
|
|
eruhenon 
      
Beiträge: 53
|
Verfasst: Fr 13.04.07 00:37
da ich es ja portabel halten möchte wie kann ich das arbeitsverzeichnis wieder aufs anwendungsverzeichnis setzen?
|
|
Lannes
      
Beiträge: 2352
Erhaltene Danke: 4
Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
|
Verfasst: Fr 13.04.07 00:39
Hallo,
mit ExtractFilePath(ParamStr(0)) bekommst Du das Anwendungsverzeichnis.
_________________ MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
|
|
eruhenon 
      
Beiträge: 53
|
Verfasst: Fr 13.04.07 00:42
|
|
|