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; |