Lasso Soft Inc. > Home

[client_param]

Linkclient_param
AuthorJason Huck
CategoryClient
Version8.x
LicensePublic Domain
Posted26 Oct 2005
Updated21 Feb 2008
More by this author...

Description

Retrieves values from [client_params] in the same manner that [action_param] retrieves values from [action_params]. An additional -explode option returns an array, for params that have multiple values. Safe to use inside [inline]. Requires [client_params] tag, available here.

Sample Usage

client_param('id');
client_param('checkme');
client_param('checkme', -count);
client_param('checkme', 2);
client_param('checkme', -explode);

-> 12345     // value of id
-> 1 2 3 4 5 // values of checkme
-> 5         // number of checkme items submitted
-> 2         // value of 2nd checkme item
-> (array: (1),(2),(3),(4),(5)) // array of checkme items

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='client_',
	-req='param',
	-opt='count',
	-opt='explode',
	-priority='replace',
	-description='Equivalent of [action_param], only for [client_params]. Safe to use inside inlines.'
);
	local('out') = string;	
	local('key') = #param;		
	
	if(params >> '-count');
		#out = client_params->find(#key)->size;
		
	else(params >> '-explode');
		#out = array;
		local('matches') = client_params->find(#key);
		
		if(#matches->size > 1);
			iterate(#matches, local('i'));
				#i->isa('pair') ? #out->insert(#i->second) | #out->insert(#i);
			/iterate;
			
		else(#matches->size);
			#matches->first->isa('pair') ? #out->insert(#matches->first->second) | #out->insert(#matches->first);
			
		/if;
		
	else(params->size >= 2 && params->get(2)->isa('integer'));
		local('index') = params->get(2);
		
		if(client_params->find(#key)->size >= #index);
			#out = client_params->find(#key)->get(#index)->second;

		else;
			#out = '';
			
		/if;	
	else;
		local('matches') = client_params->find(#key);
		
		if(#matches->size > 1);
			iterate(#matches, local('i'));
				#out += (#i->isa('pair') ? (#i->second + '\r') | (#i + '\r'));
			/iterate;
			
		else(#matches->size);
			#out = (#matches->first->isa('pair') ? #matches->first->second | #matches->first);
			
		else;
			#out = '';
		/if;
		
	/if;
	
	return(#out);
/define_tag;

Related Tags

Comments

21 Feb 2008, Jason Huck

Updated

Updated to include -explode option.

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