定义了一个Record类型,其中有一个file类型的,现不知file类型之间如何相互赋值?在线,解决马上给分。(10分)

B

Boblee

Unregistered / Unconfirmed
GUEST, unregistred user!

type myRecord = record
str:string;
myfile:file;
end;

var
myRecordArr : array of myRecord;

由于程序需要,后面我需要对myREcordArr这个数组进行移动,比如把下标在index后的前移一
个。那我就这样:
myRecordArr[index].str := myRecordArr[index + 1].str;
myRecordArr[index].myfile := myRecordArr[index + 1].myfile ;//编辑出错,告之类型不支持这种操作。

我想知道的是file类型如何相互赋值。在线,解决马上给分。
 
pointer(myRecordArr[index].myfile) := Pointer(myRecordArr[index + 1].myfile)
试试
 
不知你的目的是什么.
总觉得你把文件放到结构中,并确是无类型的文件不好.
无类型文件是要确定大小的.
myRecordArr[index].myfile := myRecordArr[index + 1].myfile
会产生溢出的错误
 
To:风云再起:
是这样的,我用TServerSocket, TClientSocket进行文件传输,允许多个Client同时时行,
于是我就要记录每个Socket及Server保存的文件。所以我就这样做了:
部分代码如下:
。。。
type
TCustClientSocketInfo = record
ClientSentFile:file;
ServerSavedFileName:string;
SentFileSize : integer;
SentFileCount : integer;
SocketHandle:integer;
ClientName :string;
ClientIP :string;
end;

ArrClientSocketInfo :array of TCustClientSocketInfo ;
。。。
当Client联上后:
procedure TiNetFaxServerFrm.addClientConnection(Socket:TCustomWinSocket);
begin
inc(nmg_intClientCount);
setLength(nmg_ArrClientSocketInfo,nmg_intClientCount);
nmg_ArrClientSocketInfo[nmg_intClientCount - 1].SocketHandle := socket.Handle;
nmg_ArrClientSocketInfo[nmg_intClientCount - 1].ClientName := Socket.RemoteHost;
nmg_ArrClientSocketInfo[nmg_intClientCount - 1].ClientIP := Socket.RemoteAddress;
//listbox1.items.Add('index: ' +IntTostr(nmg_intClientCount - 1) +' ------- Handle: '+ IntTostr(socket.Handle));
showMSGOnStatusbar(
Format('来自 %s 的新连接,当前已连的客户端数:%s',
[nmg_ArrClientSocketInfo[nmg_intClientCount - 1].ClientIP,IntTostr(nmg_intClientCount - 1)]));
Application.ProcessMessages;
Socket.SendText('yesReady');
end;
//收到文件大小后,Server建一个文件:
。。。
AssignFile([red]nmg_ArrClientSocketInfo[nmm_intCurSocketIndex].ClientSentFile[/red], nmg_strSaveFaxJobFile);
Rewrite(nmg_ArrClientSocketInfo[nmm_intCurSocketIndex].ClientSentFile, 1);
nmg_probRecFaxJob.Max := nmg_ArrClientSocketInfo[nmm_intCurSocketIndex].SentFileSize;
Socket.SendText(SOCKET_DATA)
//响应一块
上面红色的就是定义的file。

//如果传输完毕,我就要对SocketInfo这个数组进行移动,这时就碰到了我现在问的这个问题。
部分代码:
for nmm_intMoveStartIndex := nmm_intCurSocketIndex to nmg_intClientCount - 2 do
begin
nmg_ArrClientSocketInfo[nmm_intMoveStartIndex].ClientSentFile =
nmg_ArrClientSocketInfo[nmm_intMoveStartIndex + 1].ClientSentFile ;
nmg_ArrClientSocketInfo[nmm_intMoveStartIndex].ServerSavedFileName :=
nmg_ArrClientSocketInfo[nmm_intMoveStartIndex + 1].ServerSavedFileName;
。。。。

如果不用file,对我现在的要求,我能怎么更好的处理?盼高见。


 
TO 薄荷:
用你的方式,Compile时提示invalid typecast.
 
顶部