Created
March 11, 2013 15:44
-
-
Save trevordevore/5135156 to your computer and use it in GitHub Desktop.
LiveCode code that generates a UUID on OS X, Linux and Windows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateUUID | |
local theError, theUUID | |
switch the platform | |
case "macos" | |
case "linux" | |
put shell("uuidgen") into theUUID | |
put word 1 to -1 of theUUID into theUUID | |
put the result into theError | |
break | |
case "win32" | |
put format("set TypeLib = CreateObject(\"Scriptlet.TypeLib\")") into theVBScript | |
put cr & "result = TypeLib.Guid" after theVBScript | |
do theVBScript as "vbscript" | |
put the result into theresult | |
put word 1 to -1 of theresult into theressult | |
if theresult begins with "{" then | |
put char 2 to -2 of theresult into theUUID | |
end if | |
break | |
end switch | |
if theError is empty then | |
return theUUID | |
else | |
return empty | |
end if | |
end generateUUID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment