API: Cnfg
Filename:
fwpCnfg_deComment.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
Iterates through an array, presumably an array of lines from a configuration file, and removes all items that contain 'output_none', begin with #, begin with //, or are empty.
varName = fwpCnfg_deComment: varName;
text (unnamed) = required : usually a $var or #local name of variable that is an array. The array may have been created by any means, but see fwpCnfg_splitLines.
The tag does not modify the source array, so it is used like this:
local:'pureCnfgData' = fwpCnfg_deComment: $configFileArray; // or #cnfgData = fwpCnfg_deComment: #cnfgData;
<?lassoscript
//............................................................................
//
// pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*
{fileName= fwpCnfg_deComment.ctag }
{rsrcType= tag }
{rsrcName= fwpCnfg_deComment }
{rsrcHTTP= www.pageblocks.org/refc/fwpCnfg_deComment }
{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= takes an array of items (typically retrieved from a config
data file and removes items deemed non data }
{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.1 }
{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 }
{maintrelease= 5.0.0 }
{maintdate= 2006-01-16 }
{maintauthor= Greg Willits }
{maintnotes= initial release }
*/
//.............................................................................
define_tag:'fwpCnfg_deComment', -priority='replace',
-required = 'cnfgData';
($fw_debug >= fw_kVerbose) ? $fw_tagTracer->(add:'fwpCnfg_deComment', -rows = #cnfgData->size);
local:
'configData' = #cnfgData,
'cnfgLine' = string;
// remove all comments and empty lines
// must use loop because we're counting backwards to delete lines
if: #configData;
if: (#configData->type) != 'array';
$fw_error->(insert:'5201'='fwpCnfg_deComment');
$fw_debug ? $fw_apiError->(insert:'5240'=(#cnfgData->type));
$fw_debug ? $fw_tagTracer->(add:'fwpCnfg_deComment', -ERROR = 'input was not an array');
$fw_criticalLog ? log_critical:'pbError : input to fwpCnfg_deComment was not an array';
return: array;
else;
loop: -from=#configData->size, -to=1, -by=(-1);
#cnfgLine = #configData->(get:loop_count);
if: (#cnfgLine == '')
|| ((string_findRegExp: #cnfgLine, -find='\\S+')->size == 0)
|| (#cnfgLine >> 'output_none')
|| (#cnfgLine->(beginsWith:'#'))
|| (#cnfgLine->(beginsWith:'//'));
#configData->(remove:loop_count);
/if;
/loop;
return: #configData;
/if;
/if;
/define_tag;
?>
© 2002-2010, pageblocks.org