forked from simsum/oscat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CLEAN.EXP
executable file
·50 lines (38 loc) · 920 Bytes
/
CLEAN.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
49
50
(* @NESTEDCOMMENTS := 'Yes' *)
(* @PATH := '\/String' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
FUNCTION CLEAN : STRING(STRING_LENGTH)
VAR_INPUT
IN : STRING(STRING_LENGTH);
CX : STRING(80);
END_VAR
VAR
pos: INT := 1;
stop: INT;
END_VAR
(*
version 1.0 18. jun. 2008
programmer hugo
tested by oscat
Clean deletes all characters from a string except the ones specified in CX.
*)
(* @END_DECLARATION := '0' *)
(* copy input string *)
CLEAN := IN;
stop := LEN(in);
WHILE pos <= stop DO
IF FIND(cx, MID(CLEAN, 1, pos)) > 0 THEN
(* charcter found skip to next one *)
pos := pos + 1;
ELSE
(* wrong chracter needs to be deleted *)
CLEAN := DELETE(CLEAN, 1, pos);
stop := stop - 1; (* the string is one character shorter now *)
END_IF;
END_WHILE;
(* revision history
hm 18. jun. 2008 rev 1.0
original version
*)
END_FUNCTION