175
|
1 % ** TEST PROGRAM **
|
|
2 func search
|
|
3 %--- main ---
|
|
4 var dict,buf
|
|
5 array tend[2]
|
|
6 begin
|
|
7 dict := openm($2,0)
|
|
8 write(dict:ascii(0))
|
|
9 write(dict:ascii(30),ascii(-'P'),"ROC")
|
|
10 write(dict:ascii(31),ascii(-'F'),"UNC")
|
|
11 write(dict:ascii(33),ascii(-'V'),"AR")
|
|
12 postion(dict,tend)
|
|
13 buf := openm($2,0)
|
|
14 write(buf:"FUNC",ascii(0))
|
|
15 write(0:search(buf),crlf)
|
|
16 seek(buf,0)
|
|
17 write(buf:"NONAME",ascii(0))
|
|
18 write(0:search(buf),crlf)
|
|
19 end
|
|
20
|
|
21 search(buf)
|
|
22 var val,k,c
|
|
23 array bend
|
|
24 begin
|
|
25 val := seek(dict,tend)
|
|
26 position(buf,bend)
|
|
27 while val#0 do [
|
|
28 c:=seekr(buf,-1)
|
|
29 k:=seekr(dict,-1)
|
|
30 if k.lt.0 then [
|
|
31 if c=-k then
|
|
32 return val % found
|
|
33 val := seekr(dict,-1)
|
|
34 ] else if c#k then [
|
|
35 seek(buf,bend)
|
|
36 repeat
|
|
37 k:=seekr(dict,-1)
|
|
38 until k.lt.0
|
|
39 val := seekr(dict,-1)
|
|
40 ]
|
|
41 ]
|
|
42 return val % not found
|
|
43 end
|