Lasso Soft Inc. > Home

[field_list]

Linkfield_list
AuthorKe Carlton
CategoryDatabase
Version8.x
LicensePublic Domain
Posted08 Feb 2007
Updated03 Oct 2008
More by this author...

Description

Compare action_params with the datasource. Useful to track down missing fields on layouts, unsed fields or the difference between fields supplied and the datasource.

Useful when Filemaker systems fail to report problematic fields.

Sample Usage

[inline:-database='mysql',-table='db','missing field' = 123,-search]
   [field_list(-params=action_params,-mode='missing')]
[/inline]

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( 'list',
			-namespace	= 'field',
			-optional	= 'params',-copy,
			-optional	= 'mode',
			-description= '[field_list] - Compare action_params with the datasource'
			);

			//	returns: set
			//	-params: An array of pairs (typically action_params)
			//	-mode == 'missing'		=	returns set - missing fields 
			//	-mode == 'unused'		=	returns set - unused fields (not updated/searched on etc)
			//	-mode == 'difference'	=	returns set - difference between source and target field sets
			//	-mode else				=	returns set - target's fields
			
	fail_if: (local:'params')->type != 'array',-2, #_ref': Requires an array of pairs (action_params)';
	
	!(local_defined:'mode')	? local:'mode'='default';
	
	local:'_copyParams'	= '-Database,-Table,-Layout'->split(',');
	local:'_actionFields'	= set;
	local:'_inline'			= array;
	local:'_ref'			= 'field_'+tag_name;
	
	//	Seperate fields from "-params"
	iterate:#params,(local:'pair');
		local:'_param'	= string(#pair->get(1));
		local:'_value'	= string(#pair->get(2));
		
		#_param->beginsWith('-')=='false'?
			#_actionFields->insert(#_param)
				| (#_copyParams >> #_param ? #_inline->insert(#_param = #_value));				
	/iterate;
	
	fail_if: #_inline->size == 0		, -2, #_ref': Missing schema params';
	fail_if: #_inline !>> '-Database'	, -2, #_ref': database param';
	fail_if: #_inline !>> '-Layout' && #_inline !>> '-Table' , -2, #_ref': Missing -table or -layout param';
	
	//	Pull true field names
	inline:#_inline,-show;
		local:'_tableFields' = set;
		#_tableFields->insertFrom(field_names->iterator);
	/inline;
	
	if:#mode == 'missing';
		local:'_missing'=set;
		iterate:#_actionFields,(local:'_param');
			#_tablefields !>> #_param ? #_missing->insert(#_param);
		/iterate;				
		return:#_missing;
		
	else:#mode == 'unused';
		local:'_unused'=set;
		iterate:#_tablefields,(local:'_param');
			#_actionFields !>> #_param ? #_unused->insert(#_param);
		/iterate;
		return:#_unused;	
				
	else:#mode == 'difference';			
		return:#_tableFields->difference(#_actionFields);

	else;
		fail:-2,Namespace_Current #_ref': Unknown mode: '#mode;
	/if;
	
/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