« Back to AAU Project

Strings and arrays using GRAPHREP

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Strings and arrays using GRAPHREP
Answer
8/3/15 6:15 PM
Suppose, we have the following code, we know that this question can be done using ADO script, but we would like to know if it is possible to be done in GRAPHREP,

GRAPHREP sizing:asymmetrical
AVAL t1:"Pre Condition"
AVAL t2:"Post Condition"
AVAL t3:"Pre Condition Label"
AVAL t4:"Post Condition Label"
PEN color:$F59D56 w:pt
FILL color:$EEF2F8
ELLIPSE x:0.00cm y:0cm rx:2cm ry:0.75cm
LINE x1:1.1cm x2:1.1cm y1:-0.6cm y2:0.6cm
LINE x1:-1.1cm x2:-1.1cm y1:-0.6cm y2:0.6cm
ATTR "Title" x:-.92cm y:-.5cm w:2cm h:t line-break:words
ATTR "Pre Condition Label" x:-1.5cm y:0.01cm w:c h:c
ATTR "Post Condition Label" x:1.5cm y:0.02cm w:c h:c

IF ((t1 != ""))
{
PEN color:$F59D56 w:pt
FILL color:$EEF2F8
ELLIPSE x:0.00cm y:0cm rx:2cm ry:0.75cm
LINE x1:1.1cm x2:1.1cm y1:-0.6cm y2:0.6cm
LINE x1:-1.1cm x2:-1.1cm y1:-0.6cm y2:0.6cm
POINT x:-1.5cm  y:0.0cm
ATTR "Title" x:-.92cm y:-.5cm w:2cm h:t line-break:words
ATTR "Pre Condition Label" x:-1.5cm y:0.01cm w:c h:c
ATTR "Post Condition Label" x:1.5cm y:0.02cm w:c h:c
}

Please, we need an example which takes the content of the field in "t1" as a STRING and split it by logical operators "AND", "OR" and "XOR" and returns the number of "AND", "OR"  and "XOR" operators.

RE: Strings and arrays using GRAPHREP
Answer
8/6/15 8:51 AM as a reply to Fadi Al Machot.
The proposal would be to use (LEO) Expression within the GRAPHREP and represent the result of these expressions. A brief example can be seen below, applying the String token functions (see the definition here) and control logic in GRAPHREP

Assuming the STRING in t1 looks somewhat like this:
"A AND B OR C AND D XOR F OR G AND K..."

you can write the following within the GRAPHREP to retrieve the number of ANDs

1SET t1:"A AND B OR C AND D XOR F OR G AND K"
2SET andCount:0
3FOR word in: (t1) {
4    IF (word = "AND") {
5      SET andCount: (andCount+1)
6    }
7}
8TEXT (STR andCount) x:-1.5cm y:0.01cm w:c h:c

A similar logic can be applied for OR, XORs by extending the IF condition within the loop and adding to the counter.