-
Notifications
You must be signed in to change notification settings - Fork 1
MultiLineAppend
Manipulates a string value based on character codes in the value.
Value (multiple) The string to be manipulated. A "+" denotes a line break. To access a variable value wrap the name of the variable in "<<>>" Ex: BEGIN:VCARD+VERSION:2.1+N:<>;<>+FN:<> <>+ORG:<>+TEL;HOME;VOICE:123456+TEL;CELL;VOICE:<>+ADR;HOME:;;<
>;+Email;PREF;INTERNET:<>+END:VCARDSpecName (constant) The name of the variable for operation result assignment
ErrorMessage (multiple | optional) The error message to return when any error occurs.
First looks up any variables in the Value and replaces the token with the variable value. Then breaks the Value into line by replacing the "+" with line break characters.
This document action was originally designed to support the creation of QR Code formatted vCards. It is useful for any number of scenarios. The example above is a test of the vCard format. To read more about vCards go to Wikipedia (http://en.wikipedia.org/wiki/VCard) where you will find the full list of prefixes available.
public static void MultiLineAppend(object Value, string SpecName, object ErrorMessage)
{
Break();
try
{
Regex _regex = new Regex(@"\<\<(?<Variable>[^\$]*?)\>\>", RegexOptions.Multiline);
StringBuilder sb = new StringBuilder();
int start = 0;
string value = (string)Value;
foreach (Match match in _regex.Matches(value))
{
if (match.Index > start)
sb.Append(value.Substring(start, match.Index - start));
sb.Append(Variable(match.Groups["Variable"].Value).Value);
start = match.Index + match.Length;
}
if (value.Length > start)
sb.Append(value.Substring(start));
sb.Replace("+", "\r\n");
Variable(SpecName).Value = sb.ToString();
}
catch (Exception ex)
{
throw new Four51ActionsException(ex.Message, (string)ErrorMessage);
}
}