Totally wrote this out and then realized I can't use it
Enjoy!
//this is a generator function for UUIDv4
//see spec at http://tools.ietf.org/html/rfc4122#section-4.4
//it generates a pseudo random number
//uuid is 128bit number
//y. bits 6 and 7 are zero and one, respectively, (meaning 8, 9, A, or B for y)
//4. bits 12 through 15 are 0 1 0 0 (4 when calculated)
//x. all other bits are random
//the format is as follows:
//note y,4,x labels above
// xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
FUNCTION GENERATE_UUIDv4()
//make sure the following command is called at the top of the program
//RANDOMIZE TIMER( )
hex_character AS STRING = ""
character_position AS INTEGER = 1
uuidString AS STRING = ""
REPEAT
SELECT character_position
CASE 8:
hex_character = DEC_TO_BASEHEX(RND(14)+1) + "-" //throw in a dash to conform to standard
ENDCASE
CASE 13:
//bits 12 through 15 are 0 1 0 0 (4 when calculated)
hex_character = "-4" //throw in a dash to conform to standard
ENDCASE
CASE 17:
//bits 6 and 7 are zero and one, respectively, (meaning 8, 9, A, or B for y)
hex_character = "-" + DEC_TO_BASEHEX(RND(3)+8) //throw in a dash to conform to standard
ENDCASE
CASE 20:
hex_character = DEC_TO_BASEHEX(RND(14)+1) + "-" //throw in a dash to conform to standard
ENDCASE
CASE DEFAULT:
hex_character = DEC_TO_BASEHEX(RND(14)+1)
ENDCASE
ENDSELECT
INC character_position
uuidString = uuidString + hex_character
UNTIL character_position => 32
ENDFUNCTION uuidString
FUNCTION DEC_TO_BASEHEX(int_hex_representation AS INTEGER)
//returns a hex string character from an integer
hexletter AS STRING
SELECT int_hex_representation
CASE 0:
hexletter = "0"
ENDCASE
CASE 1:
hexletter = "1"
ENDCASE
CASE 2:
hexletter = "2"
ENDCASE
CASE 3:
hexletter = "3"
ENDCASE
CASE 4:
hexletter = "4"
ENDCASE
CASE 5:
hexletter = "5"
ENDCASE
CASE 6:
hexletter = "6"
ENDCASE
CASE 7:
hexletter = "7"
ENDCASE
CASE 8:
hexletter = "8"
ENDCASE
CASE 9:
hexletter = "9"
ENDCASE
CASE 10:
hexletter = "a"
ENDCASE
CASE 11:
hexletter = "b"
ENDCASE
CASE 12:
hexletter = "c"
ENDCASE
CASE 13:
hexletter = "d"
ENDCASE
CASE 14:
hexletter = "e"
ENDCASE
CASE 15:
hexletter = "f"
ENDCASE
CASE DEFAULT:
hexletter = ""
ENDCASE
ENDSELECT
ENDFUNCTION hexletter