Number List - Does anyone know why

I have a number list where I have to remove 1 element from it based on user selection. This formula works just fine except if the first or last element of the list has to be removed.

Now, I know it’s because when I set QTYBef or QTYAft equal to “” when Before or After is equal to 0. My solution is below under “Last Line Rewritten”.

What I want to know is how do I avoid the @if statement in the last line of code. What do I set the fields QTYBef & QTYAft to other than “” so Notes accepts it and performs the operation? Right now it basically ignores that line of code with an error.

Thanks for your help, Quin

Here’s the code:

Before := @TextToNumber(Selection) - 1;

After := @Elements(Row) - @TextToNumber(Selection);

QTYBef := @If(Before=0;“”;@Subset(QTY;Before));

QTYAft := @If(After=0;“”;@Subset(QTY;(After*(-1))));

FIELD QTY := QTYBef : QTYAft

Last Line Rewritten:

FIELD QTY := @If(QTYBef=“”;QTYAft; QTYAft=“”;QTYBef; QTYBef : QTYAft);

Subject: Number List - Does anyone know why…

Use @Trim around your QTYBef and QTYAft variables to get rid of the empty entries.

Subject: Number List - Does anyone know why…

Your code should work as posted (well the last Line rewritten version). To prevent ambiguity you may want to explicitly convery QTYBef / QTYAft to text in your test i.e.

FIELD QTY:=@If(@text(QTYBef)=“”;QTYAft; @text(QTYAft)=“”;QTYBef; QTYBef : QTYAft);

Although R6 shouldn’t choke without it.

Not sure if it is a mistake or deliberate but the variable After is based on @Elements(Row) yet your values appear to be stored in a field called QTY?!

HTH - Rufus.