LISTSERV Maestro 11.1-2 Help Table Of Contents

Calculation Formulas

Back to Calculation Formulas Overview
Back to Functions Overview


Function "SetToStringWithMaxLen"

SetToStringWithMaxLen(set, maxlen [, omissionText [, default [, separator [, delimiter [, delimitAll [, delimiterEscape]]]]]])

Function: This is a specialized version of the SetToString function. SetToStringWithMaxLen also converts a set into a text string, but observes a given maximum text length, by listing only so many values from the set as may fit into the maximum length. Similarly to SetToString, the values are separated with a specified separator character and optionally enclosed in the specified delimiters. If not all values fit the maximum length, then optionally an omission text may be appended.

The SetToStringWithMaxLen function is useful if you want to make sure that the final output length of the converted set does not exceed a certain limit. For example the maximum of 900 characters if the formula is used in a *Calc system drop-in, or 100 characters if the formula is used in the derivation rule of a derived profile field.

Note: If this function is used with a multi select field from a subscriber list as the set argument, then it can only be used in the message content itself and not on a landing page, because multi select fields are not supported on landing pages.

Return-Type: Text

Arguments:
set - Type Number Set or Text Set: The set that is to be converted into a text.
maxlen - Type Number: The maximum length for the resulting text. If a positive "maxlen" is supplied, then the returned text will never be longer than this value (although it may be shorter if there are not enough elements in the set). If "0" or a negative "maxlen" is supplied, the returned text will always be an empty text string.
 
(The following argument is optional.)

omissionText - Type Text: If at least one of the elements from the set has to be left out from the enumeration because of the specified "maxlen", then this "omissionText" will be appended to the resulting text, to signify that some values have been left out.

Note: The length of the omission text also counts against the given maximum length. Therefore, if an omission text is to be appended (because some values have been left out), but with the omission text the result would then be too long, then even more values will be left out until there is enough space to fit in the omission text too.

If you do not want an omission text to appear at all, then specify an empty text string "" for this argument.

Special Feature: If inside of the omission text you specify the placeholder #COUNT (with this exact spelling, in all UPPERCASE), then this placeholder will be replaced with the number of omitted elements before the omission text is appended. Therefore, if you specify the text "and #COUNT more", and in the result twelve elements have been omitted, then the omission text in the result will read "and 12 more". If not specified, then "..." is used as the default omission text.
 
The remaining arguments "default", "separator", "delimiter", "delimitAll", and "delimiterEscape" work exactly as with the SetToString function. Please see there for details. These arguments are optional but may be supplied if the "omissionText" argument has been supplied too.

Examples:
SetToStringWithMaxLen(&MULTI_SELECT_FIELD;, 100)
SetToStringWithMaxLen(&MULTI_SELECT_FIELD;, 100, " and more...", "empty")
SetToStringWithMaxLen(&MULTI_SELECT_FIELD;, 200, " and #COUNT more...", "empty", "; ")
SetToStringWithMaxLen(&MULTI_SELECT_FIELD;, 200, "", "empty", "; ", "'")
SetToStringWithMaxLen(&MULTI_SELECT_FIELD;, 200, "", "", "; ", "'", false)
SetToStringWithMaxLen(&MULTI_SELECT_FIELD;, 200, "", "", "; ", "'", true, "\")

© 2002-2023 L-Soft Sweden AB. All rights reserved.