int Split(AnsiString SourceStr,AnsiString * TargetStr,AnsiString SplitChar)
{
int i0=1,i1=1,Count=0;//i0表示子串的起始位置,i1表示結束位置,Count子串計數器
if(SourceStr.Length() >0)//如果有內容,加上一個分隔符
SourceStr+=SplitChar;
for (i1=1;i1<=SourceStr.Length();i1++)
if(SourceStr.SubString(i1,SplitChar.Length())==SplitChar)
{
TargetStr[Count]=SourceStr.SubString(i0,i1-i0);
i0=i1+SplitChar.Length();
i1=i0-1;
Count++;
};
return Count;
}
int Split(AnsiString SourceStr,TStringList *TargetStr,AnsiString SplitChar)
{
TargetStr->Clear();
int i0=1,i1=1,Count=0;//i0桶尨赽揹腔&#63232;宎弇离ㄛi1桶尨賦旰弇离ㄛCount赽揹數杅&#63239;
if(SourceStr.Length() >0)//&#63537;彆衄囀&#63527;ㄛ樓奻珨跺煦路睫
SourceStr+=SplitChar;
for (i1=1;i1<=SourceStr.Length();i1++)
if(SourceStr.SubString(i1,SplitChar.Length())==SplitChar)
{
TargetStr->Add(SourceStr.SubString(i0,i1-i0));
i0=i1+SplitChar.Length();
i1=i0-1;
Count++;
};
return Count;
}
/*///////////////ex:
TStringList* MyList = new TStringList();
Split("aaa,efg",MyList,",");
for( int i=0;i<MyList->Count;i++)
{
r->Lines->Add(MyList->Strings);
}
delete MyList;
*/
//---------------------------------------------------------------------------
__fastcall TFMain::TFMain(TComponent* Owner)
: TForm(Owner)
{
sFileNo=FileNo;
// sFileNo="1 2 3";
String stmp=sFileNo.Trim();
while(stmp.Pos(" ")!=0) //
{
String sChange=stmp;
sChange.Delete(stmp.Pos(" "),2);
sChange.Insert(" ",stmp.Pos(" "));
stmp=sChange;
}
AnsiString Par[10];
int i=0;
sFileNo=stmp;
while(stmp.Pos(AnsiString(" "))!=0)
{
stmp.Delete(stmp.Pos(AnsiString(" ")),1);
i++;
}
if(i>=2)
{
Type="1";
Split(sFileNo,Par," ");
systemCode=Par[0].Trim();//系統代碼
dataSource=Par[1].Trim()
//資料來源
docTxnNo=Par[2].Trim();//交換互動編號
}
else
{
Type="3";
Split(sFileNo,Par," ");
//Log_ROrg=Par[1].Trim();//
Seq=Par[0].Trim()
//公文序號
}
Added=false
//Count.dbf是否累加了
}