File: mseek.cat

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (49 lines) | stat: -rw-r--r-- 1,745 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
mseek            Scilab Group            Scilab Function              mseek
NAME
   mseek - set current position in binary file.
  
CALLING SEQUENCE
 mseek(n [,fd, flag])     
PARAMETERS
 n          :a positive scalar: The offset from origin in number of bytes.
            
 fd         : scalar. The fd parameter returned by the function mopen. -1
            stands for last opened file. Default value is -1.
            
 flag       : a string. specifies the origin. Default value 'set'.
            
DESCRIPTION
   The function mseek() sets the position of the next input or output
  operation on  the stream fd. The new position is at the signed distance
  given by n bytes from  the  beginning,  from the current position, or
  from the end of the file, according  to the  flag value which can be
  'set', 'cur' or 'end'.  mseek() allows the file position indicator to be
  set  beyond the  end of the existing data in the file.  If data is later
  written at this point, subsequent reads of data in  the  gap will  return
   zero  until  data is actually written into the gap.  mseek(), by itself,
  does not extend the  size  of  the file.
  
EXAMPLE
 file3='test3.bin'
 fd1= mopen(file3,'wb');
 for i=1:10, mput(i,'d'); end 
 mseek(0);
 mput(678,'d');
 mseek(0,fd1,'end');
 mput(932,'d');
 mclose(fd1)
 fd1= mopen(file3,'rb');
 res=mget(11,'d')
 res1=[1:11]; res1(1)=678;res1($)=932;
 if res1<>res ;write(%io(2),'Bug');end;
 mseek(0,fd1,'set');
 // trying to read more than stored data 
 res1=mget(100,'d',fd1);
 if res1<>res ;write(%io(2),'Bug');end;
 meof(fd1)
 mclearerr(fd1)
 mclose(fd1);
SEE ALSO
   mclose, meof, mfprintf, fprintfMat, mfscanf, fscanfMat, mget, mgetstr,
  mopen, mprintf, mput, mputstr, mscanf, mseek, mtell