to 教父:
问题通过类型文件的读取已经解决,分奉上。代码如下,思路是建立类型的子类型,
并在子类型循环。
type //第1,3层结构
Tlevel_1=packed record
az_1:word;
el_1:smallint;
year_1:smallint;
month_1:shortint;
day_1:shortint;
hour_1:shortint;
minute_1:shortint;
second_1:shortint;
flag_1:shortint;
ku_1:array[0..919]of smallint;
end;
type //第2,4层 结构的子结构
Tsu_pu=packed record
su:smallint;
pu:smallint;
end;
type //第2,4层结构
Tlevel_2=packed record
az_1:word;
el_1:smallint;
year_1:smallint;
month_1:shortint;
day_1:shortint;
hour_1:shortint;
minute_1:shortint;
second_1:shortint;
flag_1:shortint;
su_pu:array[0..919] of Tsu_pu;
//库数920 gatenum的值
end;
type //第5-11层 结构的子结构
Tqdu_su_pu=packed record
qdu:smallint;
su:smallint;
pu:smallint;
end;
type //第5,6层结构
Tlevel_5_6=packed record
az_1:word;
el_1:smallint;
year_1:smallint;
month_1:shortint;
day_1:shortint;
hour_1:shortint;
minute_1:shortint;
second_1:shortint;
flag_1:shortint;
qdu_su_pu:array[0..919] of Tqdu_su_pu;
//库数920
end;
type //第7层结构
Tlevel_7=packed record
az_1:word;
el_1:smallint;
year_1:smallint;
month_1:shortint;
day_1:shortint;
hour_1:shortint;
minute_1:shortint;
second_1:shortint;
flag_1:shortint;
qdu_su_pu:array[0..859] of Tqdu_su_pu;
//库数860
end;
type //第8层结构
Tlevel_8=packed record
az_1:word;
el_1:smallint;
year_1:smallint;
month_1:shortint;
day_1:shortint;
hour_1:shortint;
minute_1:shortint;
second_1:shortint;
flag_1:shortint;
qdu_su_pu:array[0..699] of Tqdu_su_pu;//库数700
end;
type //第9层结构
Tlevel_9=packed record
az_1:word;
el_1:smallint;
year_1:smallint;
month_1:shortint;
day_1:shortint;
hour_1:shortint;
minute_1:shortint;
second_1:shortint;
flag_1:shortint;
qdu_su_pu:array[0..439] of Tqdu_su_pu;//库数440
end;
type //第10层结构
Tlevel_10=packed record
az_1:word;
el_1:smallint;
year_1:smallint;
month_1:shortint;
day_1:shortint;
hour_1:shortint;
minute_1:shortint;
second_1:shortint;
flag_1:shortint;
qdu_su_pu:array[0..339] of Tqdu_su_pu;
//库数340
end;
type //第11层结构
Tlevel_11=packed record
az_1:word;
el_1:smallint;
year_1:smallint;
month_1:shortint;
day_1:shortint;
hour_1:shortint;
minute_1:shortint;
second_1:shortint;
flag_1:shortint;
qdu_su_pu:array[0..279] of Tqdu_su_pu;
//库数280
end;
type
TmyHead=packed record
nfn:smallint;
nname:array[0..19]of char;
pname:array[0..19]of char;
sname:array[0..19]of char;
sno:array[0..19]of char;
rtn:array[0..19]of char;
lontxt:array[0..19]of char;
lattxt:array[0..19]of char;
londeg:longint;
latdeg:longint;
siteh:longint;
levx:smallint;
levb:smallint;
rtype:smallint;
ag:word;
beanwidver:word;
beanwidhor:word;
polar:word;
lobel:word;
wavelen:longword;
power:longword;
logdyr:word;
linedyr:word;
agc:word;
logminpower:word;
lineminpower:word;
noisethr:word;
do
pplthr:word;
sqi:word;
velproc:word;
grclproc:word;
zchan:word;
zrangc:word;
stype:word;
nstep:word;
year:word;
month:word;
day:word;
hour:word;
minute:word;
second:word;
gpstime:longword;
clib:word;
nzinte:word;
nvproc:word;
datatype:array[0..29]of byte;
unfold:array[0..29]of byte;
prf1: array [0..29]of word;
prf2:array [0..29]of word;
pulswid: array [0..29]of word;
niqu:array [0..29]of word;
maxrange: array [0..29]of word;
aznum:array [0..29]of word;
gatenum:array [0..29]of word;
gatewid: array [0..29]of word;
firstgate:array [0..29]of word;
step: array [0..29]of smallint;
datform:shortint;
zbyte:shortint;
vbyte:shortint;
wbyte:shortint;
zno:smallint;
vno:smallint;
wno:smallint;
zmininc:smallint;
vmininc:smallint;
wmininc:smallint;
zzero:smallint;
vzero:smallint;
wzero:smallint;
year0:word;
month0:word;
day0:word;
hour0:word;
minute0:word;
second0:word;
gpstime0:longword;
stlbyte:word;
code1:array[0..9] of smallint ;
begin
1:array[0..9] of smallint;
end1:array[0..9] of smallint;
content1:array[0..9] of smallint;
rf:smallint;
daima:array[0..1]of char;
year1:word;
month1:word;
day1:word;
hour1:word;
minute1:word;
second1:word;
//第1层到第11层
level1:array [0..365]of Tlevel_1;
level2:array [0..365]of Tlevel_2;
level3:array [0..365]of Tlevel_1;
level4:array [0..365]of Tlevel_2;
level5:array [0..370]of Tlevel_5_6;
level6:array [0..370]of Tlevel_5_6;
level7:array [0..370]of Tlevel_7;
level8:array [0..367]of Tlevel_8;
level9:array [0..364]of Tlevel_9;
level10:array [0..362]of Tlevel_10;
level11:array [0..360]of Tlevel_11;
end;
var
Form1: TForm1;
myhead:TmyHead;
head:file of TmyHead;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
ss:tstringlist;
begin
ss:=tstringlist.Create;
opendialog1.Execute;
if opendialog1.FileName<>'' then
begin
assignfile(head,opendialog1.FileName);
Reset(head);
read(head,myhead);
。。。。。
现有两个问题请教:
1、在类型TmyHead中的level1。。level11中的数组是常量,数组的维数是从myhead.aznum
中读取的,子类型qdu_su_pu:array[0..279] of Tqdu_su_pu也是如此 一般情况下
它们不变,但如果变化,怎样使用动态数组来读取?
2、对上述的几个子类型是否可建立一个可变类型?几个子类型的长度不相等。如果能建,
怎样读取可变类型中的指定的子类型?