ParsePath()

MaysonG@aol.com
Fri, 22 Nov 1996 22:47:38 -0500

Here's another little routine that's probably already in Oberon/F
(maybe in half a dozen places in half a dozen versions <g>), and
probably should be public (assuming that it isn't already, and I
didn't miss it searching the documentation and browsing the
interfaces).

PROCEDURE ParsePath (path: ARRAY OF CHAR; VAR loc: Files.Locator; VAR name:
Files.Name);
VAR
start, i, pos: LONGINT;
BEGIN
start := 0; pos := 0; NEW(loc); loc := Files.dir.This("");
WHILE (loc.res = 0) & (pos < Strings.Len(path)) & (pos >= 0) DO
Strings.Find(path, "/", start, pos);
IF pos > 0 THEN
FOR i := start TO pos - 1 DO name[i - start] := path[i]; END; name[i -
start] := 0X; start := pos + 1;
loc := loc.This(name);
ELSE
FOR i := start TO Strings.Len(path) DO name[i - start] := path[i] END;
name[i - start] := 0X;
END;
END;
END ParsePath;

-- Mayson --