21 lines
730 B
Text
21 lines
730 B
Text
search: procedure () returns (fixed binary);
|
|
declare haystack (0:9) character (200) varying static initial
|
|
('apple', 'banana', 'celery', 'dumpling', 'egg', 'flour',
|
|
'grape', 'pomegranate', 'raisin', 'sugar' );
|
|
declare needle character (200) varying;
|
|
declare i fixed binary;
|
|
declare missing_needle condition;
|
|
|
|
on condition(missing_needle) begin;
|
|
put skip list ('your string ''' || needle ||
|
|
''' does not exist in the haystack.');
|
|
end;
|
|
|
|
put ('Please type a string');
|
|
get edit (needle) (L);
|
|
do i = lbound(haystack,1) to hbound(haystack,1);
|
|
if needle = haystack(i) then return (i);
|
|
end;
|
|
signal condition(missing_needle);
|
|
return (lbound(haystack,1)-1);
|
|
end search;
|