Expressions and GraphRepExpressions and GraphRepRE: Expressions and GraphRepWilfrid Utzhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=16003072019-06-11T13:21:41Z2019-06-11T13:21:41ZHi Nena,<br />in case you want to visualize things from the INTERREFs, you can do that directly in the GRAPHREP. The ATTR attribute (also available in the documentation page here: <a href="https://www.adoxx.org/live/adoxx-notation-language-graphrep">https://www.adoxx.org/live/adoxx-notation-language-graphrep</a> ) allows you to format things and perform required iterations. Expressions (as documented in here: <a href="https://www.adoxx.org/live/expressions">https://www.adoxx.org/live/expressions</a>) are supported in GRAPHREP directly. The examples can be used as an "inspiration" how things can be done.<br /><br /><strong>Example A: Formatting INTERREFs in GRAPHREP</strong><br />Let an ATTR element contain <div class="code"><span class="code-lines">1</span>format:"%o (%c) @ %m (%t)"</div>For a reference to a modeling object "Zappa" of class "Host" in a model "1st floor" of model type "Local area" the resulting output would be<div class="code"><span class="code-lines">1</span>Zappa (Host) @ 1st floor (Local area)</div><br />The following format syntax is supported:<br />%m ... the name (basename with version) of the referenced model,<br />%M ... the basename of the referenced model (if versioning is active),<br />%v ... the short version number of the referenced model (if versioning is active),<br />%V ... the long version number of the referenced model (if versioning is active),<br />%t ... the model type name of the referenced model,<br />%o ... the name of the referenced object (just for object references),<br />%c ... the class name of the referenced object (just for object references).<br /><br /><strong>Example B: Multiple INTERREFs in GRAPHREP with separator</strong><br />Let "Referenced models" be a multi-reference INTERREF attribute. The following displays all names of the referenced models separated by commas:<div class="code"><span class="code-lines">1</span>ATTR "Referenced mdels" format:"%m" sep:", "</div><br />By default, multiple references are displayed using one line per reference (at least if there is no reference taking more than one line). That means the default for sep is "\r\n". (The \r character has no effect here and has just been retained for historical reasons.) By setting the sep string multiple references can, for example, be displayed in one line, keeping the hyperlink functionality working.<br /><br /><strong>Example C: Alternative text for Single References</strong><br />Let "Referenced document" be a single-reference INTERREF attribute. For that, we want just a fixed text "" being displayed as hyperlink:<div class="code"><span class="code-lines">1</span>ATTR "Referenced document" text:"[refdoc]"</div><br />Specifying text at an ATTR element allows that instead of the attribute value any text can be displayed, while the text area is still working as click region for the referenced attribute. For a single-reference attribute, that means that any text can be displayed as hyperlink, being linked with the referenced model or object.<br /><br /><strong>Example D: Using AVAL and ATTR/text for a single-reference INTERREF attribute</strong><br /><br />Let "Referenced document" be a single-reference INTERREF attribute. We want at most ten characters of the referenced object's name to be displayed. At first the name of the referenced object are read into a string variable using AVAL. Then the string value is truncated if it is too long. The result is used as replacement for the value which would normally be displayed by ATTR:<br /><div class="code"><span class="code-lines">1</span>AVAL set-format:"%o" ref:"Referenced document"<br /><span class="code-lines">2</span>SET ref: (cond(LEN ref <= 10, ref, copy(ref, 0, 10))<br /><span class="code-lines">3</span>ATTR "Referenced document" text: (ref)<br /></div><br />If you want the displayed text being computed from the original attribute value, you need an AVAL ement. The AVAL element writes the value of a certain attribute into a runtime variable. The format for an INTERREF attribute can be specified with set-format. Note that it is important to write set-format before the assigned variable. The read attribute value can be used to compute the value being displayed by ATTR/text.<br /><br />Example E: Using AVAL and ATTR/text for a multi-reference INTERREF attribute<br /><br />Let "Referenced documents" be a multi-reference INTERREF attribute. We want at most ten characters of each referenced object's name to be displayed. The displayed references shall put in one line, separated by colons.<div class="code"><span class="code-lines"> 1</span>AVAL set-format:"%o" set-sep:":" ref:"Referenced documents"<br /><span class="code-lines"> 2</span>SET ref: (<br /><span class="code-lines"> 3</span> set(r, ""),<br /><span class="code-lines"> 4</span> fortok(t, ref, ":", (<br /><span class="code-lines"> 5</span> set(r, cond(LEN r, r + ":", "") +<br /><span class="code-lines"> 6</span> cond(LEN t <= 10, t, copy(t, 0, 10)))<br /><span class="code-lines"> 7</span> )),<br /><span class="code-lines"> 8</span> r)<br /><span class="code-lines"> 9</span>ATTR "Referenced documents" text: (ref) format:"%o" sep:":"<br /></div><br />At first, the names of the referenced objects are read into a string variable using AVAL. AVAL computes a string value for each reference and concatenates them using a specified string or newline as separator. Here, we specify set-sep:":".At next, each reference's text is truncated to a maximum length of 10 using a fortok expression.The computed text is displayed using ATTR with text. As explained above, it is important to specify format and sep here.<br /><br />For multiple references it is not a priori determinable which part of the text value belongs to which reference. The specified text may contain anything. So the hyperlink mechanism does not work here without a little help of the customizer. Although the text is already given, the ATTR element needs a sep and a format specification here. The sep string must be the separator which is used in the text value. The format string must be in a way, that the produced order of references is the same as the order in the text value. Otherwise following a hyperlink could lead to a wrong destination. Probably the text value has been produced from a string which comes from an AVAL element. So the format value of the ATTR element has to be the same as the set-format value of the AVAL elementWilfrid Utz2019-06-11T13:21:41ZExpressions and GraphRepNena Basinahttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=15993292019-06-18T10:42:43Z2019-06-10T12:01:57ZI have a little bit of a difficulty understanding how expressions work.<br /><br />I have an attribute of a class called "Arguments" of type INTERREF and the max refs are set to 5. On the GraphRep of the class I want to display different results depending on the number of refs (with the "AfterEditAttributeValue" event). <br />Can I achieve that directly into the GraphRep or do I need to define an expression attribute that takes a number from 1 to 5 depending on the refs? And how do I do that?<br /><br />Thank you in advance!Nena Basina2019-06-10T12:01:57Z