Files
St.Clair/MLMStripper/bin/Debug/UTIL/UTIL_STRING_BETWEEN.mlm

87 lines
1.6 KiB
Plaintext

maintenance:
title: String Parsing MLM ;;
mlmname: UTIL_STRING_BETWEEN;;
arden: version 2;;
version: 1.00;;
institution: Eclipsys Corporation;;
author: ;;
specialist: ;;
date: 2006-04-07;;
validation: testing;;
library:
purpose:
Takes a string and extract out a sub string between a start and end character.
If there is no end character specified it is assumed to be the same as the start character.
If no start or end character then the single quote is assumed.
If the string contains multiple copies of start and end characters then the final string will be a concatenation of all
these strings.
Returns the sub-string.
;;
explanation:
;;
keywords:
;;
knowledge:
type: data-driven;;
data:
( str,
startChar,
endChar
) := ARGUMENT;
;;
evoke: /* Call MLM */
;;
logic:
if str is NOT NULL then
// Default to single quote if start character is missing
if startChar is NULL then
startChar := "{{{SINGLE-QUOTE}}}"; // single quote
endif;
if endChar is NULL then
endChar := startChar; // Same as start
endif;
characterList := extract characters str;
cnt := count (characterList);
indexList := 1 SEQTO cnt;
newList := ();
saveChar := false;
for X in indexList do
ch := characterList[X];
if ch = endChar AND saveChar = true then
saveChar := false;
ch := "";
endif;
if saveChar then
newList := newList, ch;
endif;
if ch = startChar and saveChar = false then
saveChar := true;
endif;
enddo;
newString := string( newList );
endif;
conclude true;
;;
action:
return newString ;
;;
Urgency: 50;;
end: