output java between

Hello,

I’ve the gap-workflow from @AlexanderFillbrunn from rule-based rowfilter check numbers of different rows .

How can i change the java snippet node from the java between format to a string ?

hi ? wüsste jmd ne Antwort ? @AlexanderFillbrunn hättest du vllt eine Ergänzung ?

:frowning:

Hi @Paddymaster,

Switch Return Type to String
New Method Body:

String[] between = new String[$A$ - $A(-1)$ - 1];
for (int i = 0; i < between.length; i++) {
	between[i] = Integer.toString($A(-1)$ + 1 + i);
}
return between;

That’s all.

Best regards
Andrew

1 Like

hi, thx Andrew. But the Problem is th efollowing. I want to extract the data into a Excel file. The Format is now string, but the Returntype is nevertheless between. Its not possible to extract between into a xlsx file :frowning:

But

Hi @Paddymaster,

oh yes, that’s right. The Returntype from Java Snippet is List (Collection of: String) because the output from original Java Snippet was List (Collection of: Number (integer)). If you need the Returntype String you could use

int count = $A$ - $A(-1)$ - 1;
String between = "";
for (int i = 0; i < count; i++) {
	between = between + Integer.toString($A(-1)$ + 1 + i) + ", ";
}
return between.substring(0,between.lastIndexOf(", "));

Now the Returntype is String, comma seperated, if there are more than one entry.

Is that what you wanted?

Best regards
Andrew

hi @Andrew_Steel. thx for your code.

unfortunately i get an error if i try your code.

Invalid settings:
Unable to compile expression
ERROR at line 20
Type mismatch: cannot convert from java.lang.String to java.lang.String
Line: 19 }
Line: 20 return between.substring(0.between.lastIndexOf(", "));

Hi @Paddymaster,

oh yes, uncheck Array Return

1 Like

well thats right; dont see that. If i have a to big diff number the strings is unbelievable long.

is there a possibility to say --> if i have more than 5 numbers, make after that " , … " .

i tried some code. But my code was wrong ^^;)

if you need the numbers for further use, then that is a matter of visualisation …

well yeah.

sry, i explained this a little bit bad.

if i have a row with a big differnce the result is ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)

better is ( 1, 2, 3, …) or ( 1, 2, 3, … 11, 12)

Hi @Paddymaster,

I’m afraid I can’t quite follow you … if you need the result numbers, than use the above Java-code … if you didn’t need the numbers or if you need both, numbers and visualisation, you could use the above Java-code plus the following quick&dirty Java-code (second Java-Snippet):

int count = $A$ - $A(-1)$ - 1;
int lower = count;
int upper = 0;

if (count > 3)
    lower = 3;
if (count <= 5)
    lower = count;
if (count > 6)
    upper = count - 2;

String between = "";

for (int i = 0; i < lower; i++) {
	between = between + Integer.toString($A(-1)$ + 1 + i) + ", ";
}

if (lower == count)
    return between.substring(0,between.lastIndexOf(", "));
if (upper > 0) {
    between = between + "..., ";
    for (int i = upper; i < count; i++) {
        between = between + Integer.toString($A(-1)$ + 1 + i) + ", ";
    }
}
return between.substring(0,between.lastIndexOf(", "));

I hope it makes sense …
Andrew

1 Like

thx :wink: thats the coolest solution

1 Like