[lp_include_directory]

Description

Link: [lp_include_directory]
Author: Bil Corry
Category: Include
Version: 8.5.x
License: Public Domain
Posted: Sep. 02, 2006
Updated: Dec. 03, 2007
More by this author...

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

Requires [lp_file_trimPath] [lp_file_listdirectory]

Parameters

-directory string, required The directory path to include all files in.
-ignoreprefix string, optional Optionally ignore any file with this prefix.
-silent boolean, optional Optionally suppress error messages. Default is to allow errors.
-subdir boolean, optional Optionally include any sub-directories. Default is to include only the directory specified.

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
[

	/*	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 += '<br>Error loading ' #directory #item ' - the error is ' error_currenterror '<br>';
						/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

none

Email:


Password:



Newest

Most Popular