Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/libsim/splita.sim
There is 1 other file named splita.sim in the archive. Click here to see a list.
OPTIONS(/E/C/-A/-I/-D);
EXTERNAL INTEGER PROCEDURE search;
INTEGER PROCEDURE splita(t,del,ta,n);
TEXT t,del;   TEXT ARRAY ta;   INTEGER n;
!
This procedure splits the text T into parts as divided
by the text delimiter DEL and makes the elements of
TA[1:N] denote the different parts of T (without DEL).
The returned value SPLITA is the number of parts found.
However, if more than N parts are found, the value -1 is
returned.
is recommended. SPLITC is approx. twice as efficient as SPLITA.
Author: Mats Ohlin, FOA 1, Fack, S-104 50 STOCKHOLM 80, SWEDEN.
Date: 760916
;
BEGIN   INTEGER i,p;
    OPTIONS(/A); ta[1]:- ta[n];; ! Check array bounds;
    OPTIONS(/-A);
    t.Setpos(1);
    FOR i:= i+1 WHILE t.More DO
    IF i>n THEN
    BEGIN   splita:= -1;   GOTO exit   END
    ELSE
    BEGIN   p:= t.Pos;
	t.Setpos(search(t,del));
	ta[i]:- t.Sub(p,t.Pos-p);
	t.Setpos(t.Pos+del.Length);
    END;
    splita:= i-1;
    FOR i:= i STEP 1 UNTIL n DO ta[i]:- NOTEXT;
    exit:
END of splita;