我在程序中需要将时间转换成longint类型!原语句如下:
Index1Write1[K].date:=strtoint(formatdatetime('yyyymmdd',now));
Index1Write1[K].time:=strtoint(formatdatetime('hhmmss',now));
Index1Write1是我定义的一个record。其中date和time是longint类型。
但是每次运行到此处有时出错,不是错在date就是错在time上,有的时候又不出错!
都搞晕我了!
有没有高手帮忙看看,是什么问题!
我这个record中要求date,time必须是4个字节,而且是long型,所以只能定义为longint!
大人们帮帮忙啦!
谢谢先啦!
Index1Write1[K].date:=strtoint(formatdatetime('yyyymmdd',now));
Index1Write1[K].time:=strtoint(formatdatetime('hhmmss',now));
Index1Write1是我定义的一个record。其中date和time是longint类型。
但是每次运行到此处有时出错,不是错在date就是错在time上,有的时候又不出错!
都搞晕我了!
有没有高手帮忙看看,是什么问题!
我这个record中要求date,time必须是4个字节,而且是long型,所以只能定义为longint!
大人们帮帮忙啦!
谢谢先啦!
type1:char;
group:char;
Market:char;
date:longint;
time:longint;
title:array[0..63] of char;
filepath:array[0..79] of char;
offset:longint;
length:longint;
code:array[0..35] of char;
reserved1:array[0..55] of char;
chksum:char;
end;这个是我index1write1定义的record.
var i:longint;
begin
i:=strtoint(formatdatetime('yyyymmdd',now));
label1.Caption:=inttostr(i);
end;
结果label1.caption=20030928
Index1Write1[K].time:=strtoint(formatdatetime('hhnnss',now));
就是不行!
晕!
楼上的什么意思?
好象没改动啊!
呵呵!
主要是我刚用delphi没多久,不到一个礼拜!
这些都不是很清楚啊!
setlength(Index1Write,F10No-1);
F10StrTemp:=JudgeNo(0,14,Length(NewF10Txt)); //JudgeNo是一个函数。
NewF10Txt:=NewF10Txt+F10StrTemp;---->NewF10Txt是有初值的。
Index1Write[15].offset:=length(NewF10Txt);
NewF10Txt:=NewF10Txt+F10string;
Index1Write[15].length:=length(F10string);
Index1Write[15].type1:=#0;
Index1Write[15].group:=#4;
Index1Write[15].Market:='2';
Index1Write[15].chksum:=#0;
Index1Write[15].date:=strtoint(formatdatetime('yyyymmdd',now));
Index1Write[15].time:=strtoint(formatdatetime('hhmmss',now));----->出错点一
strcopy(Index1Write[15].filepath,PChar(FilePath));
strcopy(Index1write[15].code,PChar(Code));
strcopy(Index1Write[15].title,PChar(Bt1));--->出错点二
FillChar(Index1Write[15].reserved1,56,#0);
//////////////////////////将新的文件的索引写入
AssignFile(NFile,QLFile);//NFile是file of byte类型,qlfile是string类型,是一个带文件名的地址。
rewrite(NFile);
blockwrite(NFile,Pchar(NewF10Txt)^,length(NewF10Txt));
closefile(NFile);
IndexFile(NF10No);//这里将索引写到文件里面
FreeMem(Index1Write);
var
ArrayNo:array[1..20] of String;
I:integer;
ITemp:integer;
Str,Str1,Str2:string;
begin
if FirstNo>LastNo then
begin
result:='';
exit;
end else
begin
ArrayNO[1]:='`一、暂缺`';
ArrayNO[2]:='`二、暂缺`';
ArrayNO[3]:='`三、暂缺`';
ArrayNO[4]:='`四、暂缺`';
ArrayNO[5]:='`五、暂缺`';
ArrayNO[6]:='`六、暂缺`';
ArrayNO[7]:='`七、暂缺`';
ArrayNO[8]:='`八、暂缺`';
ArrayNO[9]:='`九、暂缺`';
ArrayNO[10]:='`十、暂缺`';
ArrayNO[11]:='`十一、暂缺`';
ArrayNO[12]:='`十二、暂缺`';
ArrayNO[13]:='`十三、暂缺`';
ArrayNO[14]:='`十四、暂缺`';
ArrayNO[15]:='`十五、暂缺`';
ArrayNO[16]:='`十六、暂缺`';
ArrayNO[17]:='`十七、暂缺`';
ArrayNO[18]:='`十八、暂缺`';
ArrayNO[19]:='`十九、暂缺`';
ArrayNO[20]:='`二十、暂缺`';
Str:='';
for i:=FirstNo to LastNo do
begin
Index1Write[I].offset:=length(Str)+JLong;
Str2:=ArrayNo[I+1];
Str2:=Str2+format('%'+InttoStr(76-length(Str2))+'s',['历史文件'])+#13#10;
Str2:=Str2+'资料暂缺'+#13#10#13#10;
Str:=Str+Str2;
Str1:='内容暂缺'+#0;
StrCopy(Index1Write[I].title,PChar(Str1));
Index1Write[I].length:=length(Str2);
Index1Write[I].type1:=#0;
Index1Write[I].group:=#4;
Index1Write[I].Market:='2';
Index1Write[I].chksum:=#0;
Index1Write[I].date:=strtoint(formatdatetime('yyyymmdd',now));
Index1Write[I].time:=strtoint(formatdatetime('hhmmss',now));
strcopy(Index1Write[I].filepath,PChar(FilePath));
strcopy(Index1write[I].code,PChar(Code));
//strcopy(Index1Write[I].filepath,PChar(trim(zqdm)+'.txt'+#0));
//strcopy(Index1write[I].code,PChar(trim(zqdm)+#0));
FillChar(Index1Write[I].reserved1,sizeof(Index1Write[I].reserved1),#0); end;
result:=str;
end;
end;〈-----------------------------------------〉
每次都在出错点一那里,NewF10Txt里面的内容就会变少一些(后面的一些没有了),然后到出错点二那里
NewF10Txt就会变成Inaccessible value了!
好奇怪啊!
谢谢先啦!
刚才提示我不能连续回复啊!还好楼上的帮我顶了下!
谢谢楼上啦!
发现可能是从JudgeNo函数里面出来后Index1Write传不出值或者说传出来的值不对!
有什么好办法吗??
一般是月份用MM,小时用mm,^_^
var
ldate,ltime:longint;
begin
ldate:=strtoint(formatdatetime('yyyymmdd',now));
ltime:=strtoint(formatdatetime('hhmmss',now));
showmessage('date='+inttostr(ldate)+',time='+inttostr(ltime));
end;