![]() |
Using UUID or GUID in the Generator |
Post Reply
|
| Author | |
Liroth
Member
Joined: 05.Jul.2013 Location: Kiel Points: 5 |
Post Options
Thanks(0)
Quote Reply
Topic: Using UUID or GUID in the GeneratorPosted: 05.Jul.2013 at 14:16 |
|
Hello,
is it possible to generate a UUID or GUID with the MetaEdit generator? If not cold I use the "external executeBlocking" command to call a function which returns me one? In the Workbench User's Guide it's not mentioned if the generator gets the output from the external call or not. Thanks for any help Liroth |
|
![]() |
|
stevek
MetaCase
Joined: 11.Mar.2008 Points: 643 |
Post Options
Thanks(1)
Quote Reply
Posted: 05.Jul.2013 at 14:48 |
|
You can use external...executeBlocking to call a command that sends its results to a text file, and then read that into a variable. external 'uuid >uuid.txt' externalBlocking
variable 'uuid' write
filename 'uuid.txt' read
close
If the command also writes a line break to the file, you'll need to strip that off (e.g. do $uuid where id {$uuid = id}).
If you need multiple UUIDs, I'd suggest you use just one executeBlocking for better performance, outputting multiple UUIDs to the file:
external 'uuid -n 100 >uuids.txt' externalBlocking
variable 'uuids' write
filename 'uuids.txt' read
close
do $uuids where id
{ /* use id in the block to give you the next uuid */
}
You could also grab the next UUID into $uuid like this:
variable 'uuids' write
$uuid = ''
do $uuids
{ if $uuid then id else $uuid = id endif
}
close Edited by stevek - 05.Jul.2013 at 14:50 |
|
![]() |
|
Liroth
Member
Joined: 05.Jul.2013 Location: Kiel Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 25.Jul.2013 at 12:44 |
|
Hello,
thanks for your help. In order to use the external uuid command I had to install the Windows SDK, now it works fine. Now I have another question. My model has two Objects: Components and Channels. They might be connected somehow. In the outputfile the connection has to be discribed via these uuids. At first there is a list of all channels with their generated uuids. In a later section the component connections are listed. These connections refere to the channels with the uuid. In order to do that I need some kind of array variable/map to group the channelnames from the model with their coresponding generated uuids to call them later. Another way would be to add a parameter to the channelobject with the uuid, which the user doesn't see but the generator writes into. So: Is it possible to make an array or map in MERL? or is it possible to write into objectproperties with MERL? or is there another approach? If nothing works I could make an external call for that too, but I'd like to keep as much as possible within MetaEdit+. |
|
![]() |
|
stevek
MetaCase
Joined: 11.Mar.2008 Points: 643 |
Post Options
Thanks(0)
Quote Reply
Posted: 25.Jul.2013 at 13:58 |
|
Absolutely! MERL has associative variables, so they can be used as a map. While writing out your Channel list, you grab the uuid and store it in a variable named after the Channel. If you have channels called A and B, the code below will store their UUIDs in $channelUuidA and $channelUuidB. foreach .Channel You can then later grab the UUIDs when you need them in a similar way, with variable...read. E.g. iterating over the Cartesian product of Components and Channels and writing out a connection for each: foreach .Component id;1 is the id of the object one level further out in the loop nesting (or further back on the stack), i.e. the Component here. You might want to build your variable names based on the oid rather than id, if the channel names aren't sufficiently unique. And of course if you prefer arrays, that's possible too: just build the variable names with numbers instead (there are earlier posts on arrays in generators and using arrays in sub-generators). There is no particular format or syntax to the variable names, and no restriction on what characters can be used when building names like this with variable/local...write/read. |
|
![]() |
|
Liroth
Member
Joined: 05.Jul.2013 Location: Kiel Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 27.Jul.2013 at 15:08 |
|
Thank you, this helped a lot!
|
|
![]() |
|
janne
MetaCase
Joined: 25.Mar.2008 Points: 58 |
Post Options
Thanks(0)
Quote Reply
Posted: 30.Jul.2013 at 11:32 |
|
Hi,
Just my "two cents": is the UUID style of unique identifier needed for some certain reason or would the object identifier (inside the same repository) satisfy your needs? MetaEdit+ can generate the unique and permanent identifier by using the "oid" command in MERL (http://www.metacase.com/support/50/manuals/mwb/Mw-5_5_8.html#Heading1283). With the MERL oid generation you could avoid the "external" calls and generation overall might be faster and generation script(s) simpler to create and debug? |
|
![]() |
|
Liroth
Member
Joined: 05.Jul.2013 Location: Kiel Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 31.Jul.2013 at 14:03 |
|
Thanks for the idea!
In my case I need these UUIDs in the outputfile because the next software uses these. I am aware of the oid command und I use it to make variables with the oid in the name and the UUID as value because the objectnames aren't unique. Edited by Liroth - 31.Jul.2013 at 14:04 |
|
![]() |
|
Post Reply
|
|
| Tweet |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |