Lasso Soft Inc. > Home

[gf_include_random]

Linkgf_include_random
AuthorGaetano Frascolla
CategoryInclude
Version8.x
LicensePublic Domain
Posted24 Oct 2007
Updated24 Oct 2007
More by this author...

Description

This tag returns a random element included in a determined directory. It can be used to include random images or pages.

Sample Usage



[include:(gf_include_random:'/path/')]

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:'gf_include_random', -optional='path';

if:(local_defined:'path')&&(file_exists:(#path));

var:'array_path'=(File_ListDirectory: (#path));

var:'size_path'=($array_path)->Size;

var:'array_clean_path'=(Array);

loop:($size_path);

var:'element'=($array_path)->(get:(loop_count));

if:!(file_isdirectory:($element));

$array_clean_path->(insert:($element));

/if;

/loop;

var:'size_clean_path'=($array_clean_path)->Size;

var:'include_number'=(Math_Random: -Min=1, -Max=($size_clean_path)+1);

var:'element_include'=($array_clean_path)->(get:($include_number));

var:'result'=(#path)+($element_include);

return:($result);

/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