| 341 |
* datファイルの一ラインを分解 |
* datファイルの一ラインを分解 |
| 342 |
*************************************************************************) |
*************************************************************************) |
| 343 |
function DivideStrLine(Line: string): TResRec; |
function DivideStrLine(Line: string): TResRec; |
| 344 |
|
const |
| 345 |
|
delimiter = '<>'; |
| 346 |
var |
var |
| 347 |
Delim: string; |
// Delim: string; |
| 348 |
|
pds, pde : PChar; |
| 349 |
|
pss, pse : PChar; |
| 350 |
begin |
begin |
| 351 |
if AnsiPos('<>', Line) = 0 then begin |
pss := PChar(Line); |
| 352 |
|
pse := pss + Length(Line); |
| 353 |
|
pds := PChar(delimiter); |
| 354 |
|
pde := pds + Length(delimiter); |
| 355 |
|
|
| 356 |
|
if AnsiStrPosEx(pss, pse, pds, pde) = nil then begin |
| 357 |
|
//if AnsiPos('<>', Line) = 0 then begin |
| 358 |
//Delim := ','; |
//Delim := ','; |
| 359 |
//Result.FType := glt2chOld; |
//Result.FType := glt2chOld; |
| 360 |
Line := CustomStringReplace(Line, '<>', '<>'); |
Line := CustomStringReplace(Line, '<>', '<>'); |
| 361 |
Line := CustomStringReplace(Line, ',', '<>'); |
Line := CustomStringReplace(Line, ',', '<>'); |
| 362 |
Line := CustomStringReplace(Line, '@`', ','); |
Line := CustomStringReplace(Line, '@`', ','); |
| 363 |
end; |
end; |
| 364 |
Delim := '<>'; |
//Delim := '<>'; |
| 365 |
Result.FType := glt2chNew; |
Result.FType := glt2chNew; |
| 366 |
//Trimしてはいけない気がする byもじゅ |
//Trimしてはいけない気がする byもじゅ |
| 367 |
Result.FName := RemoveToken(Line, Delim); |
Result.FName := RemoveToken(Line, delimiter); |
| 368 |
Result.FMailTo := RemoveToken(Line, Delim); |
Result.FMailTo := RemoveToken(Line, delimiter); |
| 369 |
Result.FDateTime := RemoveToken(Line, Delim); |
Result.FDateTime := RemoveToken(Line, delimiter); |
| 370 |
Result.FBody := RemoveToken(Line, Delim); |
Result.FBody := RemoveToken(Line, delimiter); |
| 371 |
//2ちゃんねるとかだと、本文の先頭に1つ半角空白が入っているので削除する |
//2ちゃんねるとかだと、本文の先頭に1つ半角空白が入っているので削除する |
| 372 |
//他の掲示板で、レス自体の空白かもしれないけどそれは諦める |
//他の掲示板で、レス自体の空白かもしれないけどそれは諦める |
| 373 |
Result.FBody := TrimLeft(Result.FBody); |
Result.FBody := TrimLeft(Result.FBody); |
| 375 |
if Result.FBody = '' then |
if Result.FBody = '' then |
| 376 |
Result.FBody := ' '; |
Result.FBody := ' '; |
| 377 |
|
|
| 378 |
Result.FTitle := RemoveToken(Line, Delim); |
Result.FTitle := RemoveToken(Line, delimiter); |
| 379 |
|
|
| 380 |
end; |
end; |
| 381 |
|
|
| 386 |
function RemoveToken(var s: string;const delimiter: string): string; |
function RemoveToken(var s: string;const delimiter: string): string; |
| 387 |
var |
var |
| 388 |
p: Integer; |
p: Integer; |
| 389 |
|
pos : PChar; |
| 390 |
|
pds, pde : PChar; |
| 391 |
|
pss, pse : PChar; |
| 392 |
begin |
begin |
| 393 |
p := AnsiPos(delimiter, s); |
pss := PChar(s); |
| 394 |
if p = 0 then |
pse := pss + Length(s); |
| 395 |
Result := s |
pds := PChar(delimiter); |
| 396 |
else |
pde := pds + Length(delimiter); |
| 397 |
Result := Copy(s, 1, p - 1); |
|
| 398 |
Delete(s, 1, Length(Result) + Length(delimiter)); |
pos := AnsiStrPosEx(pss, pse, pds, pde); |
| 399 |
|
if pos <> nil then begin |
| 400 |
|
p := pos - pss; |
| 401 |
|
SetString(Result, pss, p); |
| 402 |
|
Delete(s, 1, p + Length(delimiter)); |
| 403 |
|
end else begin |
| 404 |
|
Result := s; |
| 405 |
|
s := ''; |
| 406 |
|
end; |
| 407 |
end; |
end; |
| 408 |
|
|
| 409 |
|
|