view TL1/test/t4.tl1 @ 180:c3145f913f3d default tip

possible features
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 04 May 2019 11:17:42 +0900
parents 4d83154d2a78
children
line wrap: on
line source

% ** TEST PROGRAM **
FUNC SEARCH
%--- MAIN ---
VAR DICT,BUF
ARRAY TEND[2]
BEGIN
  DICT := OPENM((INT($2,0))
  WRITE(DICT:ASCII(0))
  WRITE(DICT:ASCII(30),ASCII(-'P'),"ROC")
  WRITE(DICT:ASCII(31),ASCII(-'F'),"UNC")
  WRITE(DICT:ASCII(33),ASCII(-'V'),"AR",CRLF)
  TEND := POSITION(DICT)
  BUF := OPENM(INT($2,0))
  WRITE(BUF:"FUNC",ASCII(0))
  WRITE(0:SEARCH(BUF),CRLF)
  SEEK(BUF,INT(0))
  WRITE(BUF:"NONAME",ASCII(0))
  WRITE(0:SEARCH(BUF),CRLF)
END

SEARCH(BUF)
VAR VAL,K,C
ARRAY BEND
BEGIN
  VAL := SEEK(DICT,TEND)
  BEND:=POSITION(BUF)
  WHILE VAL#0 DO [
     C:=SEEKR(BUF,-1)
     K:=SEEKR(DICT,-1)
     IF K.LT.0 THEN [
       IF C=-K THEN
          RETURN VAL    % FOUND
       VAL := SEEKR(DICT,-1)
     ] ELSE IF C#K THEN [
       SEEK(BUF,BEND)
       REPEAT
          K:=SEEKR(DICT,-1)
       UNTIL K.LT.0
       VAL := SEEKR(DICT,-1)
     ]
  ]
  RETURN VAL % NOT FOUND
END