Scilab Function

mscanf - interface to the C scanf function

mfscanf - interface to the C fscanf function

msscanf - interface to the C sscanf function

### Sequence d'appel

  `[n,v_1,...v_n]=mfscanf([niter,]fd,format)`
  `L=mfscanf([niter,] fd,format)`
  ``
  `[n,v_1,...v_n]=mscanf([niter,] format)`
  `L=mscanf([niter,]format)`
  ``
  `[n,v_1,...v_m]=msscanf([niter,]str,format)`
  `L=msscanf([niter,] str,format)`

### Parametres

- `format` : a Scilab string describing the format to use to write the remaining operands. The format operand follows, as close as possible, the C printf format operand syntax.
- `fd` :The fd parameter returned by the function `mopen` is used as a file descriptor (it's a positive integer). When specifying the fd parameter, the value -1 refers to the default file ( i.e the last opened file).
- `str` : a Scilab string.
- `nitem` : an integer, the number of times the format as to be used.
- `n` : an integer, the number of data read or -1 if EOL has been encountered before any datum has been read.
- `v_i` : Each function reads characters, interprets them according to a format, and stores the results in its output arguments. If more than $n$ output arguments are provided, the last ones `v_n+1,...v_m` are set to empty matrices.
- `L` : if all data are homogeneous they are stored in a unique vector which is returned else subsequences of same date type are stored in matrices and an mlist containing all the built matrices is returned.

### Description

The `mfscanf` function reads characters from the stream `fd`.

The `mscanf` function reads characters from Scilab window.

The `msscanf` function reads characters from the Scilab string `str`.

The `niter` optional argument specifies how many time the format has to used. One iteration produces one line in the output matrix. If `niter==-1` the function iterates up to the end of file. The `niter` default value is 1.

### Exemples

    s='1 1.3'
    [n,a,b]=msscanf(s,"%i %e")
    msscanf(s,"%i %e")

    msscanf(" 12\n",'%c%c%c%c') //scan characters

    msscanf('0xabc','%x') //scan with hexadecimal format

    msscanf('012345abczoo','%[0-9abc]%s')  //[] notation

    //create a file with data
    u=mopen(TMPDIR+'/foo','w');
    t=(0:0.1:%pi)';mfprintf(u,"%6.3f %6.3f\n",t,sin(t))
    mclose(u);

    //read the file line by line
    u=mopen(TMPDIR+'/foo','r');
    [n,a,b]=mfscanf(u,'%e %e')
    l=mfscanf(u,'%e %e')
    mclose(u);

    //use niter
    [n,Names,Ages]=msscanf(-1,["Alain 19";"Pierre 15";"Tom 12"],'%s %d')
    D=msscanf(-1,["Alain 19";"Pierre 15";"Tom 12"],'%s %d')
    typeof(D)
    Names=D(:,1) //strings
    Age=D(:,2)  //numerical values

    u=mopen(TMPDIR+'/foo','w');
    mfprintf(u,"%s\n",["Alain 19";"Pierre 15";"Tom 12"])
    mclose(u);

    u=mopen(TMPDIR+'/foo','r');
    [n,Names,Ages]=mfscanf(2,u,'%s %d')
    mclose(u);

### Voir aussi

`mclose` `meof` `mfprintf` `fprintfMat` `mfscanf` `fscanfMat` `mget` `mgetstr` `mopen` `mprintf` `mput` `mputstr` `mscanf` `mseek` `mtell`