-
Notifications
You must be signed in to change notification settings - Fork 1
/
callfemm.m
69 lines (60 loc) · 1.43 KB
/
callfemm.m
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
61
62
63
64
65
66
67
68
69
% ActiveFEMM (C)2006 David Meeker, [email protected]
function z=callfemm(x)
global ifile ofile HandleToFEMM
isWindows = ispc;
isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0;
if (exist('actxserver') && isWindows)
z=invoke(HandleToFEMM,'mlab2femm',x);
if (length(z)~=0)
if (z(1)=='e')
error(sprintf('FEMM returns:\n%s',z));
else
z=strrep(z,'I','i');
z=eval(z);
end
end
else
% Form that I'd previously used in Octave:
try
[fid,msg]=fopen(ifile,'wt');
catch
[fid,msg]=fopen(ifile,'w');
end
fprintf(fid,'flput(%s)',x);
fclose(fid);
if (isOctave)
do
do
try
[fid,msg]=fopen(ofile,'rt');
catch
[fid,msg]=fopen(ofile,'r');
end
if (fid==-1) pause(0.001); end
until (fid~=-1)
u=fgets(fid);
fclose(fid);
until (u~=-1)
z=eval(u);
else
u=-1; fid = -1;
while (u ==-1)
while (fid ==-1)
try
[fid, msg]=fopen(ofile,'rt');
catch
[fid, msg]=fopen(ofile,'r');
end
if (fid==-1)
pause(0.001);
end
end
u=fopen(fid);
fclose(fid);
end
z=(u);
end
pause(0.001);
delete(ofile);
%z=eval(u);
end