Changeset 2 for trunk/UFormMain.pas
- Timestamp:
- Aug 18, 2017, 10:28:14 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:ignore
set to
lib
CC2SVN.lps
CC2SVN.exe
CC2SVN.res
-
Property svn:ignore
set to
-
trunk/UFormMain.pas
r1 r2 207 207 208 208 procedure TFormMain.JobLoad(Job: TJob); 209 type 210 TParseState = (psTime, psHumanName, psUserName, psOperation, psLocation, 211 psElementType, psCommand, psComment, psNewLine); 209 212 var 210 213 Lines: TStringList; 211 214 HistoryItem: THistoryItem; 212 215 Content: string; 216 State: TParseState; 217 Text: string; 218 StartIndex: Integer; 219 I: Integer; 213 220 begin 214 221 Lines := TStringList.Create; … … 219 226 Lines.LoadFromFile('log.txt'); 220 227 {$ENDIF} 221 Job.Progress.Max := Lines.Count;222 228 Content := Lines.Text; 223 while Length(Content) > 0 do begin 224 HistoryItem := THistoryItem.Create; 225 HistoryItem.Time := XMLTimeToDateTime(ParseLine(Content, '|')); 226 HistoryItem.HumanName := ParseLine(Content, '|'); 227 HistoryItem.UserName := ParseLine(Content, '|'); 228 HistoryItem.Operation := ParseLine(Content, '|'); 229 HistoryItem.Location := ParseLine(Content, '|'); 230 HistoryItem.ElementType := ParseLine(Content, '|'); 231 HistoryItem.Command := ParseLine(Content, '|'); 232 HistoryItem.LabelName := ParseLine(Content, '|'); 233 HistoryItem.Comment := ParseLine(Content, '|'); 234 if Copy(Content, 1, 2) = #13#10 then Delete(Content, 1, 2); 235 History.Add(HistoryItem); 229 Job.Progress.Max := Length(Content); 230 StartIndex := 1; 231 State := psTime; 232 I := 1; 233 while I < Length(Content) do begin 234 if Content[I] = '|' then begin 235 Text := Copy(Content, StartIndex, I - StartIndex); 236 StartIndex := I + 1; 237 if State = psTime then begin 238 HistoryItem := THistoryItem.Create; 239 HistoryItem.Time := XMLTimeToDateTime(Text); 240 State := psHumanName; 241 end else 242 if State = psHumanName then begin 243 HistoryItem.HumanName := Text; 244 State := psUserName; 245 end else 246 if State = psUserName then begin 247 HistoryItem.UserName := Text; 248 State := psOperation; 249 end else 250 if State = psOperation then begin 251 HistoryItem.Operation := Text; 252 State := psLocation; 253 end else 254 if State = psLocation then begin 255 HistoryItem.Location := Text; 256 State := psElementType; 257 end else 258 if State = psElementType then begin 259 HistoryItem.ElementType := Text; 260 State := psCommand; 261 end else 262 if State = psCommand then begin 263 HistoryItem.Command := Text; 264 State := psComment; 265 end else 266 if State = psComment then begin 267 HistoryItem.Comment := Text; 268 History.Add(HistoryItem); 269 State := psNewLine; 270 end; 271 end else 272 if State = psNewLine then begin 273 if Content[I] = #10 then begin 274 State := psTime; 275 StartIndex := I + 1; 276 end; 277 end; 278 Inc(I); 279 280 Job.Progress.Value := I; 236 281 if Job.Terminate then Break; 237 282 end;
Note:
See TracChangeset
for help on using the changeset viewer.