Skip to content

Instantly share code, notes, and snippets.

@trevordevore
Created March 11, 2013 15:44
Show Gist options
  • Save trevordevore/5135156 to your computer and use it in GitHub Desktop.
Save trevordevore/5135156 to your computer and use it in GitHub Desktop.
LiveCode code that generates a UUID on OS X, Linux and Windows.
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