-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathisinptok.m
52 lines (43 loc) · 1.25 KB
/
isinptok.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
function [ok,data]=isinptok(data,type)%is input ok?
% Author: Tomas Melin <dr.tomas.melin@gmail.com>
% Keywords: Input checker.
%
% Revision History:
% Råberga, 2016-11-24 : move to input function.
% Bristol, 2007-06-27 : Addition of new header. TM
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if type==1; %data should be a numerics
if ischar(data)
if sum(strcmp(data,{'b' 'B'})); %is data 'b' or 'B'?
ok=-1; %signal back menu
return
elseif sum(strcmp(data,{'q' 'Q'})); %is data 'q' or 'Q'?
ok=-2; %signal escape menu
return
elseif isempty(str2num(data)); %Is data another string?
ok=0;
return
end
end
if isempty(data)
ok=0;
return
end
elseif type==2 %Data should be a string
if ischar(data)
if sum(strcmp(data,{'b' 'B'})); %is data 'b' or 'B'?
ok=-1; %signal back menu
return
elseif sum(strcmp(data,{'q' 'Q'})); %is data 'q' or 'Q'?
ok=-2; %signal escape menu
return
end
end
if isempty(data)
ok=0;
return
end
end
data=data(1);
ok=1;
end