forked from simsum/oscat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CAPITALIZE.EXP
executable file
·48 lines (39 loc) · 978 Bytes
/
CAPITALIZE.EXP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(* @NESTEDCOMMENTS := 'Yes' *)
(* @PATH := '\/String' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
FUNCTION CAPITALIZE : STRING(STRING_LENGTH)
VAR_INPUT
str : STRING(STRING_LENGTH);
END_VAR
VAR
PT : POINTER TO BYTE;
pos : INT;
L : INT;
first : BOOL := TRUE;
END_VAR
(*
version 1.2 20. jun. 2008
programmer hugo
tested by tobias
capitalize returns str with all first letters after a blank or beginning of the string are converted to uppercase.
*)
(* @END_DECLARATION := '0' *)
PT := ADR(CAPITALIZE);
CAPITALIZE := str;
L := LEN(str);
FOR pos := 1 TO l DO
IF first THEN pt^ := TO_UPPER(pt^); END_IF;
(* remember in first if the next char needs to capitalized *)
first := pt^= 32;
PT := pt + 1;
END_FOR;
(* revision histroy
hm 4. mar 2008 rev 1.0
original release
hm 29. mar. 2008 rev 1.1
changed STRING to STRING(STRING_LENGTH)
hm 20. jun. 2008 rev 1.2
improved performance
*)
END_FUNCTION