-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathconcore_iport.m
More file actions
23 lines (23 loc) · 828 Bytes
/
concore_iport.m
File metadata and controls
23 lines (23 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function [result] = concore_iport(target)
global concore;
s = concore.iports;
target = strcat('''',target,''':');
result = 0;
for i = 1:length(s)-length(target)+1;
if isequal(s(i:i+length(target)-1),target)
for j = i+length(target):length(s)
if isequal(s(j),',')||isequal(s(j),'}')
% Safe numeric parsing (replaces unsafe eval)
port_str = strtrim(s(i+length(target):j-1));
result = sscanf(port_str, '%f');
if isempty(result)
% Keep the initialized default value (0) if parsing fails
result = 0;
end
return
end
end
end
end
display(strcat('no such port:',target));
end