MODULE SVGUtilities;
IMPORT Strings, KernelLog;
PROCEDURE Log*(msg: ARRAY OF CHAR);
BEGIN
KernelLog.String(msg); KernelLog.Ln
END Log;
PROCEDURE Warning*(msg: ARRAY OF CHAR);
BEGIN
KernelLog.String("SVG Warning: "); KernelLog.String(msg); KernelLog.Ln
END Warning;
PROCEDURE Error*(msg: ARRAY OF CHAR);
BEGIN
KernelLog.String("SVG Error: "); KernelLog.String(msg); KernelLog.Ln
END Error;
PROCEDURE IsLowercase*(ch: CHAR):BOOLEAN;
BEGIN
RETURN (ch >= "a") & (ch <= "z")
END IsLowercase;
PROCEDURE IsUppercase*(ch: CHAR):BOOLEAN;
BEGIN
RETURN (ch >= "A") & (ch <= "Z")
END IsUppercase;
PROCEDURE IsAlpha*(ch: CHAR):BOOLEAN;
BEGIN
RETURN IsLowercase(ch) OR IsUppercase(ch)
END IsAlpha;
PROCEDURE SkipWhiteSpace*(VAR i: LONGINT; s: Strings.String);
BEGIN
WHILE (s[i] = 20X) OR
(s[i] = 09X) OR
(s[i] = 0AX) OR
(s[i] = 0DX) DO INC(i) END
END SkipWhiteSpace;
PROCEDURE SkipChar*(VAR i: LONGINT; s: Strings.String; c: CHAR);
BEGIN
IF s[i] # c THEN
Error("Expected a different character");
Log(s^);
END;
INC(i)
END SkipChar;
PROCEDURE SkipCharOptional*(VAR i: LONGINT; s: Strings.String; c: CHAR);
BEGIN
IF s[i] = c THEN INC(i) END
END SkipCharOptional;
PROCEDURE SkipCommaWhiteSpace*(VAR i: LONGINT; s: Strings.String);
BEGIN
SkipWhiteSpace(i, s);
SkipCharOptional(i, s, ',');
SkipWhiteSpace(i, s);
END SkipCommaWhiteSpace;
PROCEDURE StrToFloatPos*(VAR str: ARRAY OF CHAR; VAR val: LONGREAL; VAR i: LONGINT);
VAR noStr: ARRAY 16 OF CHAR;
count: LONGINT;
BEGIN
WHILE (str[i] # 0X) & (str[i] <= " ") DO INC(i) END;
count := 0;
IF str[i] = "-" THEN
noStr[count] := str[i]; INC(count); INC(i);
WHILE (str[i] # 0X) & (str[i] <= " ") DO INC(i) END
END;
IF str[i] = "+" THEN
INC(i);
WHILE (str[i] # 0X) & (str[i] <= " ") DO INC(i) END
END;
WHILE (str[i] >= "0") & (str[i] <= "9") DO noStr[count] := str[i]; INC(count); INC(i) END;
IF str[i] = "." THEN
noStr[count] := str[i]; INC(count); INC(i);
WHILE (str[i] >= "0") & (str[i] <= "9") DO noStr[count] := str[i]; INC(count); INC(i) END;
END;
IF (str[i] = "D") OR (str[i] ="E") OR (str[i] = "d") OR (str[i] ="e") THEN
noStr[count] := CAP(str[i]); INC(count); INC(i);
IF str[i] = "-" THEN
noStr[count] := str[i]; INC(count); INC(i);
END;
WHILE (str[i] >= "0") & (str[i] <= "9") DO noStr[count] := str[i]; INC(count); INC(i) END;
END;
noStr[count] := 0X;
Strings.StrToFloat(noStr, val)
END StrToFloatPos;
END SVGUtilities.