文件内格式为dword id,dword length,string,byte length2,other. 然后循环。
怎样转为文本文件。
id=1 str=你好 other=其他
另:如果上面的格式用%d,%d%s,%b%s来表示。
那另一文件%d,%d,%d%s,怎样写一个通用的处理程序。
怎样转为文本文件。
id=1 str=你好 other=其他
另:如果上面的格式用%d,%d%s,%b%s来表示。
那另一文件%d,%d,%d%s,怎样写一个通用的处理程序。
解决方案 »
- 怎么把‘2011年09月20日 20:30:00’只取数字如20110920203000
- delphi中pointer问题
- 小弟想学习下对硬件的编程
- 公司招Delphi开发人员
- 一个 Delphi 的群:13830859
- 怎么样才能把一个FORM上的所有COMPONENT都写到一个文件中,然后再读出来显示在FORM上呢?
- 菜鸟问题 请教各位大侠~!!!!
- 请教
- 在DCOM三层结构中如何传输WORD文件,服务端方法的数据类型如何选择?
- 三层结构:两表联合修改添加问题
- 在delphi中如何使用ADOConnection直接连Mysql数据库?
- 同一个程序中多个线程同时调用相同的DLL涵数!需要注意些什么(附源吗)在线等
procedure txtProc(s: string);
var
st: TStringList;
i: integer;
function Split(s, t: string): TStringList;
begin
Result := TStringList.Create;
while SPos(t, s)>0 do
begin
Result.Add(Copy(s, 1, SPos(t, s)-1));
Delete(s, 1, SPos(t, s));
end;
if Length(s)>0 then Result.Add(s);
end;
begin
st := TStringList.Create;
st := Split(s, ',');
for i:=0 to (st.Count div 3)-1 do
Memo1.Lines.Add('id='+st[3*i+0]+#9+'str='+st[3*i+1]+#9+'other='+st[3*i+2]);
st.Free;
end;
function TForm1.SPos(t, s: string): integer;
begin
Result := Pos(AnsiLowerCase(t), AnsiLowerCase(s));
end;
04 00 00 00->4
31 32 33 34->4字节1234
05->5
31 32 33 34 35->5字节12345
我以前做过这样的东西,贴一小段 //跳过消息头
ContentIndex:=8; //提取发言人信息
Move(Msg[ContentIndex],ContentLen,2);
Inc(ContentIndex,2);
SetLength(Ret.Sender,ContentLen);
Move(Msg[ContentIndex],Ret.Sender[1],ContentLen);
Inc(ContentIndex,ContentLen);