API: Cnfg
Filename:
fwpCnfg_splitComma.ctag
Released With:
5.0.0
Current Version:
1.2.0
Status: Active
Min Lasso Tested: 8.1.0
Max Lasso Tested: 8.5.3
Related:
Still don't get it?
Check out the talk list archives, or join and ask your questions.
Documentation Error or Request?
Email documentation corrections or comments
Accepts a string of items delimited with commas and normalizes the comma usage to eliminate surrounding spaces. By default the text is then split at the comma delimiters into a Lasso array.
Normalization is performed to allow spaces to be a part of the delimited item text. The strings " , " and ", " and " ," are all replaced with a single "," character.
The normalizing function is rather useful on its own, so a -withoutSplit option is available to prevent the split, and the data is returned as a string with normalized comma delimiting.
varName = fwpCnfg_splitComma: varName;
varName = fwpCnfg_splitComma: varName, -withoutSplit;
list (unnamed) = required : literal string data or a string variable.
-withoutSplit = optional : include this param if the text is not to be split into an array.
#cnfgData = fwpCnfg_splitComma: #cnfgData; #cnfgLines = fwpCnfg_splitComma: #cnfgLines, -withoutSplit;
This code:
#cnfgData = fwpCnfg_splitComma: 'red,yellow ,blue , green';
would return
array: (red), (yellow), (blue), (green)
And this code:
#cnfgData = fwpCnfg_splitComma: 'red,yellow ,blue , green', -withoutSplit;
would return
'red,yellow,blue,green'
<?lassoscript
//............................................................................
//
// pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*
{fileName= fwpCnfg_splitComma.ctag }
{rsrcType= tag }
{rsrcName= fwpCnfg_splitComma }
{rsrcHTTP= www.pageblocks.org/refc/fwpCnfg_splitComma }
{lassoVrsnMin= 8.1.0 }
{lassoVrsnMax= 8.5.3 }
{author= Greg Willits }
{authorEmail= subscribe to pbTalk at www.pageblocks.org/talk/ }
{authorHTTP= www.pageblocks.org }
{desc= This routine converts a comma list into an array, or
using the -nosplit option simply eliminates all white
space surrounding the commas. }
{maintvsrn= 1.2.0 }
{maintrelease= 5.2.0 }
{maintdate= 2007-06-09}
{maintauthor= Greg Willits }
{maintnotes= updated debug and error handling systems,
changed some internal vars for better readability }
{maintvsrn= 1.1.0 }
{maintrelease= 5.1.0 }
{maintdate= 2006-05-30}
{maintauthor= Greg Willits }
{maintnotes= added tagTrace }
{maintvsrn= 1.0.2 }
{maintrelease= 5.0.0 b5 }
{maintdate= 2006-02-02 }
{maintauthor= Greg Willits }
{maintnotes= doh! fixed type detection logic which didn't allow
for empty input }
{maintvsrn= 1.0.1 }
{maintrelease= 5.0.0 b5 }
{maintdate= 2006-01-27 }
{maintauthor= Greg Willits }
{maintnotes= improved white space detection and removal, changed
some syntax for efficiency }
{maintvsrn= 1.0 }
{maintrelease= 5.0.0 }
{maintdate= 2006-01-16 }
{maintauthor= Greg Willits }
{maintnotes= initial release }
*/
//.............................................................................
define_tag:'fwpCnfg_splitComma', -priority='replace',
-required='list';
// -withoutSplit (-nosplit deprecated))
($fw_debug >= fw_kVerbose) ? $fw_tagTracer->(add:'fwpCnfg_splitComma', -list=(string:#list)->(getLeft:80));
local:
'configData' = local:'list',
'withoutSplit' = false;
(params->find:'-withoutSplit') || (params->find:'-nosplit')
? #withoutSplit = true;
if: #configData;
if: ((#configData->type != 'string') && (#configData->type != 'bytes'));
$fw_error->(insert:'5201'='fwpCnfg_splitComma');
$fw_debug ? $fw_apiError->(insert:'5242'=(#list->type));
$fw_debug ? $fw_tagTracer->(add:'fwpCnfg_splitComma', -ERROR = 'input was not a string or bytes type');
$fw_criticalLog ? log_critical:'pbError : input to fwpCnfg_splitComma was not a string or bytes type';
else;
#configData = (string_replaceRegExp:
#configData,
-find = '\\s*,\\s*',
-replace = ',');
!#withoutSplit
? #configData = (#configData->split:',');
return: #configData;
/if;
else;
($fw_debug >= fw_kVerbose) ? $fw_tagTracer->(add:'fwpCnfg_splitComma', -status = 'input was empty');
/if;
/define_tag;
?>
© 2002-2010, pageblocks.org