关于...我也不知了...大家帮忙看一下 了.....(50分)

  • 主题发起人 主题发起人 why_119
  • 开始时间 开始时间
W

why_119

Unregistered / Unconfirmed
GUEST, unregistred user!
00000h: F4 9B 13 FC 10 02 00 00-00 00 00 00 D1 04 00 00
00000h: 81 0C 00 00 48 0C 00 00-31 41 30 30 30 31 00 FF
00020h: FF FF B0 09 FF FF 16 00-17 00 18 00 19 00 1A 00
00030h: 1B 00 1C 00 1D 00 1E 00-07 0A FF FF FF FF FF FF
00040h: FF FF FF FF FF FF FF FF-FF FF FF FF FF FF FF FF
00050h: FF FF FF FF FF FF FF FF
...... ......
41000h: 80 47 B2 2B B9 1E 25 41-CD CC 4C 41 EC 51 18 41
41010h: 9A 99 41 41 80 06 B2 47-40 1C BC 4C 00 00 00 00
41020h: 00 3C B6 2B 34 33 3F 41-AF 47 49 41 01 00 30 41
41030h: 34 33 3B 41 00 07 12 47-A4 3C 26 4C 00 00 00 00

该文件格式与磁盘文件物理存储方式类似:
起止地址 数据内容 数据含义 数据类型
00 - 03 F4 9B 13 FC 日线文件标志 Integer
04 - 07 10 02 00 00 保留 Integer
08 - 0B 00 00 00 00 保留 Integer
0C - 0F D1 04 00 00 证券总数 Integer
10 - 13 81 0C 00 00 需添加之起始块号 Integer
14 - 17 48 0C 00 00 当前最后空块号 Integer
18 - 21 31 41 30 30 30...FF 证券代码 Char[10]
22 - 23 B0 09 日线记录数 Integer
24 - 25 FF FF 保留 Integer
26 - 57 16 00 17 00...FF FF 记录块号 Word[25]
......
41000 - 41003 80 47 B2 2B 日期 Integer
41004 - 41007 B9 1E 25 41 开盘价 Single
41008 - 4100B CD CC 4C 41 最高价 Single
4100C - 4100F EC 51 18 41 最低价 Single
41010 - 41013 9A 99 41 41 收盘价 Single
41014 - 41017 80 06 B2 47 成交量 Single
41018 - 4101B 40 1C BC 4C 成交金额 Single
4101C - 4101D 00 00 上涨家数 Word
4101E - 4101F 00 00 下跌家数 Word
应如何读出上面的数据???????????
 
正如你写的把它16进制-->10进制就可以了
 
头晕

提前!
 
眼花,
學習。
 
我写的一个读自定义结构的类,本打算做成很通用的样子,但没有实现。
现在只能读内容全为数值的文件。你看一下,会有帮助的。
用法:
TYourType=Recored
a:Integer;
b:Byte;
end
 A:=TDatas.Create;
a.RecordSize:=Sizeof(TYouType);//一定要在loadFrom前写
a.LoadFromStream(yourStream)
// 或者 a.loadfromFile(FileName);
TYourType(a.GetCurrentData^).a ;//这样就可以读了

unit FileClass;
interface
uses
classes,Sysutils,Windows
Type

TDatas= Class
private
FDataList:TList;
FPos:Integer;
FRecordSize: Integer;
FRefCount: Integer;
Function IsEof():Boolean;
Function IsBof():Boolean;
Function IsEmpty():Boolean;
procedure SetRecordSize(const Value: Integer);
protected
Public
Function GetCurrentData():Pointer;
Function GetCount():Integer;
Function GetCurrentPos():Integer
Procedure StoreData(Compare:TListSortCompare);
Procedure EmptyData();
function GetDataByIndex(Index:Integer):Pointer;
Procedure AppendData(NewData:Pointer);
procedure InsterData(Index: Integer
Item: Pointer);
Procedure RemoveCurrentData();

procedure MoveNext();
Procedure MovePrio();
Procedure MoveFirst();
Procedure MoveLast();
procedure MoveTo(NewPos:Integer);
procedure MoveBy(OffsetPos:Integer;MoveType:Word);

Procedure FindItem(Itme:Pointer;FindType:Word);

procedure LoadFromStream(Stream: TStream);
procedure LoadFromFile(FileName: String);
Procedure SaveToStream(Stream: TStream);
Procedure SaveToFile(FileName: String);

property EOF:Boolean Read IsEof
Property BOF:Boolean Read IsBof
Property Empty:Boolean Read IsEmpty;

property RecordSize:Integer read FRecordSize write SetRecordSize;
constructor Create;
destructor Destroy
override;
end

implementation

Function TDatas.IsEof():Boolean;
begin
if FPos=-2 then
IsEof:=True
else
IsEof:=False;
end
Function TDatas.IsBof():Boolean;
begin
If FPos=-1 then
IsBof:=True
else
IsBof:=False;
end

Function TDatas.GetCurrentData():Pointer;
begin
If (FPos>=0) and (FPos<FDataList.Count) then
Result:=FDataList.Items[FPos]
else
Result:=nil
end;


Constructor TDatas.Create;
begin
Inherited Create
FDataList:=TList.Create
FPos:=-3;
end

destructor TDatas.Destroy;
begin
FDataList.Clear
FDataList.Free
Inherited Destroy
end

Procedure TDatas.MoveNext();
begin
FPos:=FPos+1;
If FPos>=FDataList.Count then FPos:=-2;
end

Procedure TDatas.MovePrio();
begin
FPos:=FPos-1
If FPos<0 then FPos:=-1;
end

Procedure TDatas.MoveFirst();
begin
FPos:=0;
end

Procedure TDatas.MoveLast();
begin
FPos:=FDataList.Count-1
end

Procedure TDatas.SaveToStream(Stream: TStream);
Var
I:LongInt;
tmpRead:Pointer;
begin
FDataList.Pack
// FDataList.Sort(TListSortCompare(DayDataCmp));
For I:=0 To FDataList.Count -1 do
begin
tmpRead:=FDataList.Items;
Stream.WriteBuffer(tmpRead^,FRecordSize);
end
end

Procedure TDatas.SaveToFile(FileName:String);
Var
tmpStream:TFileStream;
begin
tmpStream:=TFileStream.Create(FileName,fmCreate);
try
SaveToStream(tmpStream);
Finally
TmpStream.Free
end
end;

Procedure TDatas.LoadFromFile(FileName:String);
var
TmpStream:TFileStream;
begin
TmpStream:=TFileStream.Create(FileName,fmOpenRead);
Try
LoadFromStream(TmpStream);
finally
TmpStream.Free
end
end

Procedure TDatas.LoadFromStream(Stream: TStream);
var
CData:Pointer;
i:Integer;
begin
FDataList.Clear
Stream.Position:=0;
for i:=0 to trunc(Stream.Size/FRecordSize)-1 do
begin
GetMem(CData,FRecordSize);
Stream.ReadBuffer(CData^,FRecordSize);
FDataList.Add(CData);
end
if FDataList.Count>0 then
FPos:=FDataList.Count-1
else
FPos:=-3;
end;

Procedure TDatas.AppendData(NewData:Pointer);
var
pTmp:Pointer;
begin
GetMem(pTmp,FRecordSize);
Move(NewData^,pTmp^,FRecordSize);
FDataList.Add(pTmp);
FPos:=FDataList.Count -1;
end

function TDatas.IsEmpty: Boolean;
begin
If FDataList.Count<=0 then
IsEmpty:=True
else
IsEmpty:=False;
end;

procedure TDatas.EmptyData;
begin
FDataList.Clear
FPos:=-3;
end;

function TDatas.GetCount: Integer;
begin
GetCount:=FDataList.Count;
end;


procedure TDatas.SetRecordSize(const Value: Integer);
begin
FRecordSize := Value;
end;

function TDatas.GetCurrentPos: Integer;
begin
Result:=FPos;
end;

procedure TDatas.MoveTo(NewPos:Integer);
begin
if NewPos<0 then
FPos:=-1
else if NewPos>=FDataList.Count then
FPos:=-2
else
FPos:=NewPos;
end;

procedure TDatas.MoveBy(OffsetPos: Integer
MoveType: Word);
begin
case MoveType of
soFromBeginning:
FPos:=OffsetPos;
soFromCurrent:
inc(FPos, OffsetPos);
soFromEnd:
FPos:=(FDataList.Count+OffSetPos)-1;
end;
if FPos<0 then
FPos:=-1
else if FPos>=FDataList.Count then
FPos:=-2
end;

procedure TDatas.StoreData(Compare: TListSortCompare);
begin
FDataList.Sort(Compare);
end;

Procedure TDatas.RemoveCurrentData;
begin
FDataList.Delete(FPos);
end;

procedure TDatas.InsterData(Index: Integer
Item: Pointer);
var
TmpPointer:Pointer;
begin
GetMem(TmpPointer,FRecordSize);
Move(item,TmpPointer,FRecordSize);
FDataList.Insert(Index,TmpPointer);
end;

procedure TDatas.FindItem(Itme: Pointer
FindType: Word);
begin
case FindType of
soFromBeginning:

soFromCurrent:

soFromEnd:

end;
end;

function TDatas.GetDataByIndex(Index: Integer): Pointer;
begin
If (Index>=0) and (Index<FDataList.Count) then
Result:=FDataList.Items[Index]
else
Result:=nil

end;

end.
 
Jobslee:你能把中文写上吗...谢谢...有时间写了...没时间就慢慢写了...
 
后退
顶部