annotate TL1/test/t4.tl1 @ 177:3770e86114aa

TL/1 fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 15 Apr 2019 04:27:18 +0900
parents 6ef317714ae8
children 4d83154d2a78
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 % ** TEST PROGRAM **
176
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
2 FUNC SEARCH
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
3 %--- MAIN ---
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
4 VAR DICT,BUF,D
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
5 ARRAY TEND[2]
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
6 BEGIN
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
7 WRITE(DICT:ASCII(0))
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
8 DICT := OPENM($2,0)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
9 WRITE(DICT:ASCII(0))
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
10 WRITE(DICT:ASCII(30),ASCII(0-'P'),"ROC")
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
11 WRITE(DICT:ASCII(31),ASCII(0-'F'),"UNC")
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
12 WRITE(DICT:ASCII(33),ASCII(0-'V'),"AR",CRLF)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
13 D:=POSITION(DICT,TEND)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
14 BUF := OPENM($2,0)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
15 WRITE(BUF:"FUNC",ASCII(0))
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
16 WRITE(0:SEARCH(BUF),CRLF)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
17 D:=SEEK(BUF,0)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
18 WRITE(BUF:"NONAME",ASCII(0))
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
19 WRITE(0:SEARCH(BUF),CRLF)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
20 END
175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
176
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
22 SEARCH(BUF)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
23 VAR VAL,K,C,D
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
24 ARRAY BEND
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
25 BEGIN
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
26 VAL := SEEK(DICT,TEND)
177
3770e86114aa TL/1 fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
27 D:=POSITION(BUF,BEND)
176
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
28 WHILE VAL#0 DO [
177
3770e86114aa TL/1 fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
29 C:=SEEKR(BUF,0-1)
3770e86114aa TL/1 fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
30 K:=SEEKR(DICT,0-1)
176
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
31 IF K.LT.0 THEN [
177
3770e86114aa TL/1 fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
32 IF C=0-K THEN
176
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
33 RETURN VAL % FOUND
177
3770e86114aa TL/1 fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
34 VAL := SEEKR(DICT,0-1)
176
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
35 ] ELSE IF C#K THEN [
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
36 D:=SEEK(BUF,BEND)
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
37 REPEAT
177
3770e86114aa TL/1 fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
38 K:=SEEKR(DICT,0-1)
176
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
39 UNTIL K.LT.0
177
3770e86114aa TL/1 fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 176
diff changeset
40 VAL := SEEKR(DICT,0-1)
175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 ]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 ]
176
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
43 RETURN VAL % NOT FOUND
6ef317714ae8 mopen in TL/1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 175
diff changeset
44 END