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
50
51
52
53
54
55
56
57
58
59
60
|
function callFunctionAcctoMethod(filename,head,exx)
head = strsubst(head," ","");
exx = strsubst(exx," ","");
f_temp = mopen(filename, 'wt');
cal_exp=strcat(["deff(""",head,""",""",exx,""")"]);
ok=execstr(cal_exp,'errcatch')
if (ok~=0) then
mfprintf(f_temp, '{""msg"":""Incorrect expression : %s""}', lasterror());
else
[ok,%ok1,ipar,rpar,%nz]=compiler_expression(%foo)
writeValueToFileFromVars(ok,%ok1,ipar,rpar,%nz,f_temp)
end
mclose(f_temp)
endfunction
function writeValueToFileFromVars(ok,ok1,ipar,rpar,nz,f_temp)
mfprintf(f_temp, '{');
if (ok == %t) then
mfprintf(f_temp, '""ok"":""%s""', 'true');
else
mfprintf(f_temp, '""ok"":""%s""', lasterror());
end
if (ok == %t) then
mfprintf(f_temp, ',""ok1"":""%s""', 'true');
else
mfprintf(f_temp, ',""ok1"":""%s""', lasterror());
end
if ((ok == %t) & (ok1 == %t)) then
mfprintf(f_temp, ',""ipar"":[');
for i = 1:length(ipar)
if (i == length(ipar)) then
mfprintf(f_temp, '[%d]', ipar(i));
else
mfprintf(f_temp, '[%d],', ipar(i));
end
end
mfprintf(f_temp, ']');
mfprintf(f_temp, ',""rpar"":[');
for i = 1:length(rpar)
if (i == length(rpar)) then
mfprintf(f_temp, '[%d]', rpar(i));
else
mfprintf(f_temp, '[%d],', rpar(i));
end
end
mfprintf(f_temp, ']');
mfprintf(f_temp, ',""nz"":[');
for i = 1:length(nz)
if (i == length(nz)) then
mfprintf(f_temp, '[%d]', nz(i));
else
mfprintf(f_temp, '[%d],', nz(i));
end
end
mfprintf(f_temp, ']');
end
mfprintf(f_temp, '}');
endfunction
|