I am new to Panorama X and would like to migrate datasets from both Filemaker and Xojo (SQLite) to Panorama X. These datasets use UUIDs for primary keys and I need to be able to generate a UUID when a new record is added.
I have no experience delving into the bit/byte/word/hex functions to brute-force this on my own (but I will try my best if I need to) so hope that a solution for Panorama X is already out there somewhere.
Well, looking at this as a specialized string of text instead of a specialized group of hexadecimal numbers I came up with my own solution. This uses the looparray to generate the 36 characters consisting of the hex numbers and the “-” character. By first creating a ghost array of 35 carriage returns to drive the looparray to cycle 36 times we can then create each character in turn and account for the needed “-” characters as well as the “4” for the 15th character and reduced range used for the 20th character. Here is the code I used:
local x,y,z
x=rep(cr(),35)
y=""
z="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F"
looparray x,cr(),element,index
if index=9 or index=14 or index=19 or index=24
y=y+"-"
elseif index=15
y=y+"4"
elseif index=20
y=y+randomarrayelement(arrayrange(z,9,12,","),",")
else
y=y+randomarrayelement(z,",")
endif
endloop
Panorama X includes a function that generates UUID’s for you. It’s based on the Apple API that you found with your web search. This string is generated by the operating system and includes the host name, process ID, a time stamp and a counter, which ensures that the ID is unique for the network. Each time this function is called it returns a new unique string.
Awesome! And thank you! (Within an hour and on a Saturday morning no-less!)
Apparently, there is a standard for UUIDs ([http://www.ietf.org/rfc/rfc4122.txt]) that requires
1. Adjust certain bits according to RFC 4122 section 4.4 as follows:
1. set the four most significant bits of the 7th byte to 0100’B, so the high nibble is “4”
2. set the two most significant bits of the 9th byte to 10’B, so the high nibble will be one of “8”, “9”, “A”, or “B”.
However, since my use doesn’t involve interface with secure and/or certifiable applications, the above functions will suit me just fine.
Being able to generate these unique record ids opens up Panorama X for me. Thank you so much
KDJ
p.s. just noticed the post that there is a Panorama X function. Wonderful.
I am curious. What would info(“guid”) be used for? And is there a function that reads the generated guid and extracts the host name, process id, time stamp and counter?
The description says
Returns a unique identifier string. This string is generated by the operating system and includes the host name, process ID, a time stamp and a counter, which ensures that the ID is unique for the network. Each time this function is called it returns a new unique string.
It would simply be used to identify something. The idea is to generate a string that is sufficiently complex, that you don’t need to worry about there being two with the same identifier.
Not possible. The host name alone can have more characters than the whole ID, so this is a one-way calculation, purely meant to assure that nobody else arrives at the same number.