CreateID

PURPOSE ^

CreateID Creates an Identifier (char)

SYNOPSIS ^

function [ID] = CreateID(method)

DESCRIPTION ^

CreateID Creates an Identifier (char)
   Creates an (sometimes unique) identifier based on the selected method
   if no method is selected method 1 will be the default method

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ID] = CreateID(method)
0002 %CreateID Creates an Identifier (char)
0003 %   Creates an (sometimes unique) identifier based on the selected method
0004 %   if no method is selected method 1 will be the default method
0005 arguments
0006     method (1,1) {mustBeNumeric} = 1
0007 end
0008 
0009 switch method 
0010     case 1 % UNIX Time in seconds as HEX
0011         ID = posixtime(datetime('now')); %get current Unix time
0012         ID = dec2hex(int32(ID)); % get it as Hex
0013         pause(0.5); %Pausing for unique IDs
0014     case 2 % random UUID from Java 128 bit
0015         %Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
0016         % The UUID is generated using a cryptographically strong pseudo random number generator.
0017         temp =  java.util.UUID.randomUUID;
0018         ID = temp.toString;           
0019      otherwise
0020         error('The requested method is not defined yet');
0021 end
0022 
0023 end

Generated on Tue 03-Aug-2021 18:32:18 by m2html © 2005