1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2008 - DIGITEO - Allan CORNET
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
8 // <-- JVM NOT MANDATORY -->
11 nstr = strcat(string(1:n),' ');
12 fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
14 ierr = execstr("sscanf(1,''%d'')", "errcatch");
15 if ierr <> 999 then pause,end
17 [A1, A2, A3, A4, A5, A6, A7, A8] = sscanf(nstr, fstr);
19 if or([A1, A2, A3, A4, A5, A6, A7, A8] <> ref) then pause,end
22 args = strcat( v(ones(n,1)) + string(1:n)',',');
23 ierr = execstr('[' + args + '] = sscanf(nstr, fstr);','errcatch');
25 ierr = execstr('r = or([' + args + '] <> ref)','errcatch');
26 if ierr <> 0 then pause,end
27 if r <> %f then pause,end
30 nstr = strcat(string(1:n),' ');
31 fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
33 args = strcat( v(ones(n,1)) + string(1:n)',',');
34 ierr = execstr('[' + args + '] = sscanf(nstr, fstr);','errcatch');
35 if ierr <> 999 then pause,end
38 nstr = strcat(string(1:n),' ');
39 fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
41 mputl(nstr,TMPDIR+'/fscanf.txt');
42 [A1, A2, A3, A4, A5, A6, A7, A8] = fscanf(TMPDIR+'/fscanf.txt',fstr);
44 if or([A1, A2, A3, A4, A5, A6, A7, A8] <> ref) then pause,end
47 args = strcat( v(ones(n,1)) + string(1:n)',',');
48 ierr = execstr('[' + args + '] = fscanf(TMPDIR+''/fscanf.txt'', fstr);','errcatch');
50 ierr = execstr('r = or([' + args + '] <> ref)','errcatch');
51 if ierr <> 0 then pause,end
52 if r <> %f then pause,end
55 nstr = strcat(string(1:n),' ');
56 fstr = strcat(strsubst(string(ones(1,n)),'1','%d'), ' ');
58 args = strcat( v(ones(n,1)) + string(1:n)',',');
59 ierr = execstr('[' + args + '] = fscanf(TMPDIR+''/fscanf.txt'', fstr);','errcatch');
60 if ierr <> 999 then pause,end
63 if sscanf('123','%i')<>123 then pause,end
64 if sscanf(' 123','%i')<>123 then pause,end
65 if sscanf('123','%2i')<>12 then pause,end
66 if sscanf('123','%0i')<>123 then pause,end
67 if sscanf('123','%5i')<>123 then pause,end
69 if sscanf('+123','%u')<>123 then pause,end
70 if sscanf(' 123','%2u')<>12 then pause,end
71 if sscanf('123','%0u')<>123 then pause,end
72 if sscanf('+123','%5u')<>123 then pause,end
73 //test format %e %f %g
75 if sscanf('123','%e')<>123 then pause,end
76 if sscanf(' 123','%e')<>123 then pause,end
77 if sscanf('123','%2e')<>12 then pause,end
78 if sscanf('123','%0e')<>123 then pause,end
79 if sscanf('123','%5e')<>123 then pause,end
82 if sscanf('123','%s')<>'123' then pause,end
83 if sscanf(' 123','%s')<>'123' then pause,end
84 if sscanf('123','%2s')<>'12' then pause,end
85 if sscanf('123','%0s')<>'123' then pause,end
86 if sscanf('123','%5s')<>'123' then pause,end
89 if sscanf('123','%o')<>83 then pause,end
90 if sscanf(' 123','%o')<>83 then pause,end
91 if sscanf('123','%2o')<>10 then pause,end
92 if sscanf('123','%0o')<>83 then pause,end
93 if sscanf('123','%5o')<>83 then pause,end
96 if sscanf('123','%x')<>291 then pause,end
97 if sscanf(' 123','%x')<>291 then pause,end
98 if sscanf('123','%2x')<>18 then pause,end
99 if sscanf('123','%0x')<>291 then pause,end
100 if sscanf('123','%5x')<>291 then pause,end
103 if sscanf('123','%c')<>'1' then pause,end
104 if sscanf(' 123','%c')<>' ' then pause,end
105 if sscanf('123','%0c')<>'1' then pause,end
107 //test des format complexes
108 if sscanf('123 4','%*s%s')<>'4' then pause,end
109 if sscanf('123 4','123%e')<>4 then pause,end
110 [a,b,c]=sscanf('xxxxx 4 test 23.45','xxxxx%i%s%e')
111 if a<>4|b<>'test'|c<>23.45 then pause,end
113 [a,b]=sscanf('123\n456','%e%e')
114 if a<>123|b<>456 then pause,end