Lasso Soft Inc. > Home

[include_once]

Linkinclude_once
AuthorJason Huck
CategoryInclude
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted26 Oct 2005
Updated16 Jan 2006
More by this author...

Description

Includes the specified file only if it has not already been included using this tag. Based on this discussion from Lasso Talk.

Requires [file_pathfromroot], available here.

Sample Usage

include_once('/path/to/file.inc');

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(
	'once',
	-namespace='include_',
	-priority='replace',
	-description='Includes the specified file only if it has not already been included.'
);
	fail_if(
		!params->size || !params->first->isa('string'),
		-1,
		'[include_once] requires a file path as a parameter.'
	);
	
	local('path') = file_pathfromroot(params->first);		
	!var_defined('included_files') ? var('included_files' = set);		
	
	if($included_files !>> #path);
		$included_files->insert(#path);
		return(include(#path));
	/if;		
/define_tag;

Related Tags

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