0001 function fiff_write_id(fid,kind,id)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 me='MNE:fiff_write_id';
0039
0040 if nargin == 2
0041 timezone=5;
0042 id.version = bitor(bitshift(1,16),2);
0043 id.machid(1) = 65536*rand(1);
0044 id.machid(2) = 65536*rand(1);
0045 id.secs = 3600*(24*(now-datenum(1970,1,1,0,0,0))+timezone);
0046 id.usecs = 0;
0047 elseif nargin ~= 3
0048 error(me,'Incorrect number of arguments');
0049 end
0050
0051 FIFFT_ID_STRUCT=31;
0052 FIFFV_NEXT_SEQ=0;
0053
0054
0055 datasize=5*4;
0056 count = fwrite(fid,int32(kind),'int32');
0057 if count ~= 1
0058 error(me,'write failed');
0059 end
0060 count = fwrite(fid,int32(FIFFT_ID_STRUCT),'int32');
0061 if count ~= 1
0062 error(me,'write failed');
0063 end
0064 count = fwrite(fid,int32(datasize),'int32');
0065 if count ~= 1
0066 error(me,'write failed');
0067 end
0068 count = fwrite(fid,int32(FIFFV_NEXT_SEQ),'int32');
0069 if count ~= 1
0070 error(me,'write failed');
0071 end
0072
0073
0074
0075 data(1) = id.version;
0076 data(2) = id.machid(1);
0077 data(3) = id.machid(2);
0078 data(4) = id.secs;
0079 data(5) = id.usecs;
0080 count = fwrite(fid,int32(data),'int32');
0081 if count ~= 5
0082 error(me,'write failed');
0083 end
0084 return;
0085