Print Page | Close Window

Enforce unique combination of parameters

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=908
Printed Date: 27.Mar.2026 at 03:35
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Enforce unique combination of parameters
Posted By: edward22243
Subject: Enforce unique combination of parameters
Date Posted: 19.Apr.2019 at 13:59
I have an object called Cell, and it represents a physical production cell in a 2D-grid (u,v).
The location are paramters u and v and the combination needs to be unique. What does not work is that I set u and v unique individually. After all (1,0) and (1,1) are diffent locations, but they have a common u, namely u=1, so it is not unique.


I solved this by defining a location as a string '(u,v)'  instead of 2 parameters. 

But I want to know how I can retrieve u and v from the string '(u,v)'  regex (\d+,\d+) 

or go back to two parameters, but add a check for unique of the combi?

Each way is okay for me.




Replies:
Posted By: stevek
Date Posted: 19.Apr.2019 at 14:21
If you want UI enforcement of global uniqueness (i.e. trying to enter (1,1) a second time anywhere will be prevented), you can mark that property slot in Cell as Unique. If you want UI enforcement of local uniqueness (i.e. trying to add a second Cell with (1,1) to the same graph will be prevented), you can add a Uniqueness Constraint to the Graph type.

In both cases, you can extract the u and v parameters with a regex translator. I'd drop the parentheses, to save the user having to read and type them all the time, and maybe allow whitespace after the comma:
to '%u
/(\d+),\s*\d+/ $$1'
endto

to '%v
/\d+,\s*(\d+)/ $$1'
endto

@u = :Location%u 
@v = :Location%v

'u is ' @u ' and v is ' @v

To make sure the users follow the legal format for Location, you can add a corresponding Regex to the property type, \d+,\s*\d+. (If you want to allow decimals, scientific notation etc., just extend \d as desired.)

If on the other hand you want to keep u and v separate, and it's OK just to show an error / warning in the model if values aren't unique, see http://www.metacase.com/support/55/manuals/mwb/Mw-6_7_4.html" rel="nofollow - 6.7.4 Checking instance uniqueness in the Workbench User Guide. If you define an Identifier Generator for the Cell object type, outputting both u and v (e.g. :u ',' :v), those examples should work as-is.


Posted By: edward22243
Date Posted: 19.Apr.2019 at 14:59
Hello Steven,

That worked. Was looking through the documentation for regex but could not really fnd it. 

Had to look for translaters instead, that works good.  



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net