Lasso Soft Inc. > Home

[lp_string_random]

Linklp_string_random
AuthorBil Corry
CategoryString
Version8.x
LicensePublic Domain
Posted07 Dec 2005
Updated07 Dec 2005
More by this author...

Description

Returns a string of random alphanumeric characters.  May specify length, default is 20 characters.

Sample Usage

var:'size' = 50;
'
';
'lp_string_random Example\r\n';
'Length = '$size'\r\n';
'+' * $size '\r\n';
loop: 50;
	(lp_string_random: $size) '\r\n';
/loop;
'+' * $size '\r\n';
'
';

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:'lp_string_random',
	-description='Returns a string of random alphanumeric characters.',
	-priority='replace',
	-optional='length';

	// based on a tag by Greg Willits

	local:'alphanumeric' = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';

	if: !(local_defined:'length');
		local:'length' = 20;
	/if;

	local:'lp_string_random' = string;
	loop:(integer:#length);
		#lp_string_random += #alphanumeric->(get:(integer:(math_random: -lower=1, -upper=62)));
	/loop;
	return: #lp_string_random;

/define_tag;

]

Comments

24 Jun 2014, Steve Piercy

Lasso 9 version on GitHub

I've released a Lasso 9 version of this method at GitHub https://github.com/stevepiercy/sp_string_random

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