¾È³çÇϼ¼¿ä. Ÿ¶ôÀÓµÂ.
Á¦°¡ ¾²´Â ¹®ÀÚ¿ ÆÄ½Ì ÇÔ¼ö ÀÔ´Ï´Ù.
function xyToken(var AList: TszString; const AText: string; const ASub: string = #13#10; const AutoSize: boolean = true): integer; overload;
function xyToken(const AText: string; const ASub: string = #13#10; const ADelim: string = #13#10): string; overload;
***** ¸ðµç µ¨ÆÄÀÌ ¹öÁ¯¿¡¼ »ç¿ë ÇÒ ¼ö ÀÖ½À´Ï´Ù *****
ù¹ø° ÇÔ¼ö´Â Á¦°¡ Áñ°Ü¾²´Â ¹®ÀÚ¿ ÆÄ½Ì ÇÔ¼ö ÀÌ°í, µÎ¹ø° ÇÔ¼ö´Â ÆÄ½Ì °á°ú¸¦ TStringList.Text À¸·Î ¹Þ±â À§ÇÑ ÇÔ¼ö ÀÔ´Ï´Ù.
¹®ÀÚ¿ ÆÄ½Ì ÇÔ¼ö¸¦ ¸¸µé¾î ¾²´Â ÀÌÀ¯´Â
TStringList ÀÇ Quoted string ÆÄ½Ì ·çƾ¿¡ ¹ö±×°¡ ÀÖ¾î¼, TStringList.CommaText := '"AB"CD", "FGHI","JK""MN"'; Çϸé
AB CD" FGHI JK"MN
°ú °°ÀÌ ¹®ÀÚ¿ÀÌ ±úÁý´Ï´Ù.
DataSet ÀÇ Record¸¦ Quoted string À¸·Î ¹ÞÀ» ¶§ µ¥ÀÌŸ¿¡ " °¡ µé¾î ÀÖÀ¸¸é µ¥ÀÌÅÍ°¡ ±úÁö´Â °ÍÀÌ ºÒÆíÇؼ, ¸¸µé¾î ¾²°í ÀÖ½À´Ï´Ù.
(example) var MyList: TszString; sID, sKind, sTheDay: string; cMoney: currency; begin ... xyToken(MyList, ARequest.mText);
if Length(MyList) < 4 then begin DoSendText(AContext, RE_ErrPacket, 'ÆÐŶ ¿¡·¯'); exit; end;
sID := MyList[0]; sTheDay := MyList[1]; sKind := MyList[2]; cMoney := StrToCurrDef(MyList[3], 0.0);
if sID <> AUser.FID then begin DoSendText(AContext, RE_ErrData, 'µ¥ÀÌŸ ¿¡·¯'); exit; end; ...
<ÇÔ¼ö ¼Ò½º>
type TszString = array of string;
function xyToken(var AList: TszString; const AText: string; const ASub: string = #13#10; const AutoSize: boolean = true): integer; overload;
function xyToken(const AText: string; const ASub: string = #13#10; const ADelim: string = #13#10): string; overload;
implementation
function xyToken(var AList: TszString; const AText: string; const ASub: string; const AutoSize: boolean): integer; var nPast, nPos, nLen, nSub: integer; begin integer(Result) := 0; nLen := Length(AText); nSub := Length(ASub);
nPos := Pos(ASub, AText); nPast := 1; while nPos > 0 do begin if Result = Length(AList) then SetLength(AList, Result + 1024);
if nPos = nPast then AList[Result] := '' else AList[Result] := Copy(AText, nPast, nPos - nPast); Result := Result + 1;
nPast := nPos + nSub; nPos := PosEx(ASub, AText, nPast); end;
if nPast <= nLen then begin if Result = Length(AList) then SetLength(AList, Result + 1); AList[Result] := Copy(AText, nPast, MaxInt); Result := Result + 1; end;
if AutoSize then SetLength(AList, Result); end;
function xyToken(const AText: string; const ASub: string = #13#10; const ADelim: string = #13#10): string; var nPos, nPast: integer; begin Result := ''; nPast := 0; nPos := Pos(ASub, AText); whil
|