question

Yue Y avatar image
0 Likes"
Yue Y asked Joshua S answered

How to generate a UUID in FlexScript

Is it possible to generate a UUID https://en.wikipedia.org/wiki/Universally_unique_identifier

of the following format with FlexScript: 123e4567-e89b-12d3-a456-426655440000?

FlexSim 19.1.1
uuid
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joshua S avatar image
2 Likes"
Joshua S answered

Not sure if there is a pattern it's supposed to follow, but you can run this in flexsim and it will give you a random UUID.

Array Lengths = [9,14,19,24,0];
int LP=1;
Array inputs = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
string UUID="";
for (int i = 1; i <= 36; i++)
{	
	if (i == Lengths[LP])
	{
		LP++;
		UUID+="-";
	}
	else	
		UUID+=inputs[duniform(1,inputs.length)];	
}
return UUID;
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.