Lasso Soft Inc. > Home

[lp_include_directory]

Linklp_include_directory
AuthorBil Corry
CategoryInclude
Version8.5.x
LicensePublic Domain
Posted02 Sep 2006
Updated03 Dec 2007
More by this author...

Description

Includes every file found in a given directory with the extension .lasso, .las, .inc, .incl.

Requires [lp_file_trimPath] [lp_file_listdirectory]

Sample Usage

(lp_include_directory:'/includes',-ignorepref='_',-silent,-subdir);

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.

[

	/*	to-do: have extensions based on LassoSite settings	*/

	define_tag:'lp_include_directory',
		-description='Includes every file found in a given directory with the extension .lasso, .las, .inc, .incl.',
		-priority='replace',
		-required='directory',-copy,
		-optional='ignoreprefix';

		// save error so we won't overwrite it with our protect below
		local:'_ec' = error_code;
		local:'_em' = error_msg;
		lp_error_clearError;

		#directory = lp_file_trimPath: #directory;

		// check for -ignorePrefix
		if: !(local_defined:'ignoreprefix');
			local:'ignoreprefix' = 'dummy value';
		/if;

		// check for -subdir option
		if: params->(find:'-subdir')->size > 0;
			local:'subdir' = true;
		else;
			local:'subdir' = false;
		/if;

		// check for -silent option (supresses error messages)
		if: params->(find:'-silent')->size > 0;
			local:'silent' = true;
		else;
			local:'silent' = false;
		/if;		

		// get file listing
		local:'listing' = (lp_file_listdirectory: #directory);
		
		// sort in alpha order
		#listing->sort;
		
		// load item by item
		local:'return' = string;
		iterate: #listing, local:'item';
			if: #item->(endswith:'.lasso') || #item->(endswith:'.las') || #item->(endswith:'.lassoapp') || #item->(endswith:'.inc') || #item->(endswith:'.incl');
				protect;
					namespace_using:'_page_'; // makes any ctags defined within include available to calling page
						#return += (include: #directory #item);
					/namespace_using;
					handle_error;
						if: !#silent;
							#return += '
Error loading ' #directory #item ' - the error is ' error_currenterror '
'; /if; /handle_error; /protect; else: #subdir && #item->(endswith:'/') && !(#item->(beginswith: #ignoreprefix)); // recursively call #return += (lp_include_directory: (#directory #item), -subdir); /if; /iterate; // restore the error, if any error_code = #_ec; error_msg = #_em; return: #return; /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