H
huxhang
Unregistered / Unconfirmed
GUEST, unregistred user!
将以下文本:"10BET","01","","1","""10BET","02","","","0""10BET","03","","1","""10BET","04","","1","""wBET","01","3","","""wBET","02","3","","""wBET","03","","","0""wBET","04","3","","""Astrabet","01","","1","""Astrabet","02","","1","""Astrabet","03","","","0""Astrabet","04","","","0"处理为:10BET:1,0,1,1wBET:3,3,0,3Astrabet:1,1,0,0目前错误的处理后:wBET:1,0,1,1Astrabet:3,3,0,31,1,0,0下面哪儿错了?procedure FormatStrs(AListSource, AListTarget: TStrings);const Cons_Space = '*';var SListSrcWord, SListTargetWord: TStringList
Sect: string
i, j: Integer
KeyWord: string
begin_word:string;begin Sect := ''
SListTargetWord := TStringList.Create
SListSrcWord := TStringList.Create
AListTarget.BeginUpdate
AListTarget.Clear
try for i := 0 to 3 do begin SListTargetWord.Add(Cons_Space)
end
for i := 0 to AListSource.Count - 1 do begin SListSrcWord.CommaText := AListSource
if SListSrcWord[0] <> Sect then begin AListTarget.Add(SListTargetWord.CommaText)
Sect := SListSrcWord[0]
for j := 1 to SListTargetWord.Count - 1 do begin SListTargetWord[j] := Cons_Space
begin_word:= Format('%s', [SListSrcWord[0]])
end
end
KeyWord := Format('%s%s%s', [SListSrcWord[2], SListSrcWord[3], SListSrcWord[4]])
begin_word:= Format('%s', [SListSrcWord[0]])
if (KeyWord = '') then begin KeyWord := Cons_Space
end
SListTargetWord[StrToInt(SListSrcWord[1]) - 1] := KeyWord
end
// AListTarget.Text:=begin_word+':'
AListTarget.Add(begin_word+':'+SListTargetWord.CommaText)
finally SListTargetWord.Free
SListSrcWord.Free
end
if AListTarget.Count > 0 then begin AListTarget.Delete(0)
end
AListTarget.EndUpdate;end;procedure TForm1.btn1Click(Sender: TObject);begin FormatStrs(Mmo1.Lines, Mmo2.Lines);end;
Sect: string
i, j: Integer
KeyWord: string
begin_word:string;begin Sect := ''
SListTargetWord := TStringList.Create
SListSrcWord := TStringList.Create
AListTarget.BeginUpdate
AListTarget.Clear
try for i := 0 to 3 do begin SListTargetWord.Add(Cons_Space)
end
for i := 0 to AListSource.Count - 1 do begin SListSrcWord.CommaText := AListSource
if SListSrcWord[0] <> Sect then begin AListTarget.Add(SListTargetWord.CommaText)
Sect := SListSrcWord[0]
for j := 1 to SListTargetWord.Count - 1 do begin SListTargetWord[j] := Cons_Space
begin_word:= Format('%s', [SListSrcWord[0]])
end
end
KeyWord := Format('%s%s%s', [SListSrcWord[2], SListSrcWord[3], SListSrcWord[4]])
begin_word:= Format('%s', [SListSrcWord[0]])
if (KeyWord = '') then begin KeyWord := Cons_Space
end
SListTargetWord[StrToInt(SListSrcWord[1]) - 1] := KeyWord
end
// AListTarget.Text:=begin_word+':'
AListTarget.Add(begin_word+':'+SListTargetWord.CommaText)
finally SListTargetWord.Free
SListSrcWord.Free
end
if AListTarget.Count > 0 then begin AListTarget.Delete(0)
end
AListTarget.EndUpdate;end;procedure TForm1.btn1Click(Sender: TObject);begin FormatStrs(Mmo1.Lines, Mmo2.Lines);end;