Link | B_UUID |
Author | Douglas Burchard |
Category | Custom Tag |
Version | 8.5.x |
License | Public Domain |
Posted | 25 Sep 2009 |
Updated | 25 Sep 2009 |
More by this author... |
This custom prototype returns a version 4 (random) Universally Unique Identifier (UUID). For more information on UUIDs, please read the Wikipedia entry, currently at: http://en.wikipedia.org/wiki/uuid
B_UUID
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.
// ===================================================================== /* B_UUID -------------------------------------------------------------------- =========================================== | B_UUID | =========================================== | Tags ------------------------------------------- | onCreate() String | ToHex(Integer) String | ToChar(Integer) String | GenerateNumber(Integer,Integer) Integer | GenerateUUID() String | This custom prototype returns a version 4 (random) Universally Unique Identifier (UUID). For more information on UUIDs, please read the Wikipedia entry, currently at: http://en.wikipedia.org/wiki/uuid */ // --------------------------------------------------------------------- Define_Type('UUID', -NameSpace='B_', -Prototype, -Description='This custom prototype returns a version 4 (random) ' + 'Universally Unique Identifier (UUID). For more information ' + 'on UUIDs, please read the Wikipedia entry, currently at: ' + 'http://en.wikipedia.org/wiki/uuid.'); Define_Tag('onCreate'); Return(String(Self -> GenerateUUID)); /Define_Tag; Define_Tag('ToHex', -Required='d', -EncodeNone); Local('r' = (#d % (16))); Local('result'); If((#d - #r) == (0)); #result = (Self -> ToChar(#r)); Else; #result = ((Self -> ToHex((#d - #r) / (16))) + (Self -> ToChar(#r))); /If; Return(#result); /Define_Tag; Define_Tag('ToChar', -Required='n', -EncodeNone); Local('alpha' = '0123456789abcdef'); Return(#alpha -> Get(#n + (1))); /Define_Tag; Define_Tag('GenerateNumber', -Required='l', -Required='u', -EncodeNone); Local('n' = Math_Random(-Lower=(Local('l') - (1)), -Upper=Local('u'))); #n = ((#n < Local('l')) ? Local('u') | (#n)); Return(#n); /Define_Tag; Define_Tag('GenerateUUID', -EncodeNone); Local('random_bytes' = String); #random_bytes += (Self -> ToHex(_date_msec)); #random_bytes -> Reverse; While((#random_bytes -> Size) < (30)); #random_bytes += (Self -> ToHex(Self -> GenerateNumber((0), (15)))); /While; #random_bytes -> Lowercase; #random_bytes = String_Insert(#random_bytes, -Position=(9), -Text='-'); #random_bytes = String_Insert(#random_bytes, -Position=(14), -Text='-4'); #random_bytes = String_Insert(#random_bytes, -Position=(19), -Text=('-' + (Array('8','9','a','b') -> Get(Self -> ToHex(Self -> GenerateNumber((1), (4))))))); #random_bytes = String_Insert(#random_bytes, -Position=(24), -Text='-'); Return(#random_bytes); /Define_Tag; /Define_Type; // =====================================================================
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
This tag is very useful, but I have had issues...