Lasso Soft Inc. > Home

[lp_logical_in]

Linklp_logical_in
AuthorBil Corry
CategoryConditional
Version8.x
LicensePublic Domain
Posted03 Dec 2005
Updated03 Dec 2005
More by this author...

Description

Evaluates if a value is contained within a list of elements.  Returns true or false.

Sample Usage

(lp_logical_in:'abc',(:'abc','def'));
(lp_logical_in:'abc','abc,def,ghi');
(lp_logical_in:'gh','abc,def,ghi');

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

[

define_tag:'lp_logical_in',
	-description='Searches a list of elements for an item.  Returns true or false.',
	-priority='replace',
	-required='value', -copy,
	-required='list',
	-optional='list_delimiter';
	
	local:'trim' = true;
	if: params->(find:'-notrim') > 0;
		local:'trim' = false;
	else: #value->type == 'string';
		#value->trim;
	/if;

	if: #list->type == 'array';
		local:'listarray' = #list;
	else;
		if: local_defined:'list_delimiter';
			local:'listarray' = (string:#list)->(split:#list_delimiter);
		else; // assume comma-delimited
			local:'listarray' = (string:#list)->(split:',');
		/if;
	/if;

	iterate: #listarray, local:'item';
		if: #trim && #item->type == 'string';
			#item->trim;
		/if;
		if: #item == #value;
			return: true;
		/if;
	/iterate;
	return: false;

/define_tag;

]

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft