Lasso Soft Inc. > Home

[rp_param]

Linkrp_param
AuthorRandy Phillips
CategoryClient
Version8.5.x
LicensePublic Domain
Posted25 Jun 2007
Updated13 Jul 2007
More by this author...

Description

I created this  tag to bypass the "built in" error that occurs when the find->get element does not exist in a pair array. It gets values from pair arrays such as client_postparams or client_getparams without throwing an error when the element does not exist. Instead it silently returns a NULL value.

Sample Usage

local('fruit' = (array: 'item1' = 'apples', 'item2' = 'bananas', 'item1' = 'strawberries', 'item3' = 'oranges'));

(rp_param: -pairs=(#fruit), -find='item1');

//->apples

(rp_param: -pairs=(#fruit), -find='item1', -instance=2);

//->strawberries

(rp_param: -pairs=(#fruit), -find='item1', -instance=3);

//->NULL

(rp_param: -pairs=(#fruit), -find='item7');

//->NULL

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:'param', -namespace='rp_',
	
	-required='pairs', -type=array,
	
	-required='find',
	
	-optional='instance';
	
	!(local_defined:'instance') ? local('instance' = 1);
	
	!(local_defined:'value') ? local('value' = NULL);
	
	local('param_count' = #pairs->(find:#find)->size);
	
	
	loop(#param_count);
	
		local('value' = #instance <= (loop_count) ? #pairs->(find:#find)->(get:#instance)->value | NULL);
	
	/loop;
	
		return: #value;
		
/define_tag;

Related Tags

Comments

25 Jun 2007, Johan Solve

Horray!

Great, Randy!

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