new UUID from Wally.

This commit is contained in:
george 2010-05-20 21:45:02 +00:00
parent 7ee1301fc7
commit 6be9afaee1
1 changed files with 7 additions and 1 deletions

View File

@ -21,7 +21,13 @@ C0CUTIL ;WV/C0C/SMH - Various Utilites for generating the CCR/CCD;06/15/08
W "No Entry at Top!"
Q
;
UUID() ; GENERATE A RANDOM UUID (Version 4)
UUID() ; thanks to Wally for this.
N R,I,J,N
S N="",R="" F S N=N_$R(100000) Q:$L(N)>64
F I=1:2:64 S R=R_$E("0123456789abcdef",($E(N,I,I+1)#16+1))
Q $E(R,1,8)_"-"_$E(R,9,12)_"-4"_$E(R,14,16)_"-"_$E("89ab",$E(N,17)#4+1)_$E(R,18,20)_"-"_$E(R,21,32)
;
OLDUUID() ; GENERATE A RANDOM UUID (Version 4)
N I,J,ZS
S ZS="0123456789abcdef" S J=""
F I=1:1:36 S J=J_$S((I=9)!(I=14)!(I=19)!(I=24):"-",I=15:4,I=20:"a",1:$E(ZS,$R(16)+1))