The important general idea is this:

Use the @-buffer to get the result of the i-desc calculation from the *previous* record to apply it to the calculation for the *current* record. (RetrieVe inits @-buffers to null (which goes to 0) when the sentence executes.)

I don't think this works for UD's uniQuery. From Martin's response, I'm guessing not for QM, either.

Kate's non-compound solution, "@1+F1", is superior to my own, "@2+F1; @1",
because it allows nesting this I-descriptor inside a 2nd. For example, if you want to use this as part of running-weighted-averages. Better still, "ADDS(@,F1)" or "@ + SUMMATION( @ )" because they handle multivalues.
I knew you all could come up with the details to suit your purposes.

The important piece of the puzzle is extracting the previous record's calculation for use in the next record's calculation.

Another example of the same idea is to see if a value has changed & process accordingly, effectively a breakpoint control inside an i-descriptor:

<2> : @2; CUST.ID; IF @1 = @2 THEN [logic for same customer as last time] ELSE [logic for next customer]

(The above would only be useful on a presorted list.)

cds

On 7/4/2013 5:04 AM, Kate Stanton wrote:
I could only find doc for this in the System Description manual, where it
talks about using @ in I-type expressions, where @ is the previous one
(just resolved), @1 is result of first "sentence" (separated by ;), @2 is
result of 2nd sentence, etc.  I could not see an example of using the
result from the previous record, but it works.

BTW, with multi-values, ADDS(@1,F26) works.  V1 of first record adds to V1
of 2nd, etc.  I can't think of where we could use it, but it depends on
your file structure.


On 4 July 2013 11:47, Peter Cheney <peter.che...@firstmac.com.au> wrote:

I believe the expression in the second example is referred to as a
compound expression?

Can't put my finger on the exact documentation but I seem to recall that
compound expressions are broken up into "parts" (for want of a better term)
delimited by a ';' and each "part" can be referenced throughout the entire
expression by an @ number e..g. @1 refers to the first part and the nth
part is @n etc.

So for:
LIST VOC SIZE EVAL "SIZE + @2;@"

My take on how this works is the the first part of the expression (SIZE +
@2) can be referenced later on as @1, The second part is referenced as @
(instead of @2) and I believe is used to refer to the result of the entire
expression (sum of all the parts).

Can @ in this case also be referenced as @2? It probably could but would
break the expression.

Therefore the reference to @2 is causing the expression to grab the entire
result using contents of @ (via @2 thus keeping it separate to @) and add
it to SIZE which then becomes the new result (@) of the expressions and the
whole thing is repeated.

Does that sound about tight? Or have I got it way wrong?

Cheers
Peter




Peter Cheney

Universe Engineer

t 07 3017 8837 | f 07 3002 8400

e peter.che...@firstmac.com.au | w www.firstmac.com.au



________________________________________
From: u2-users-boun...@listserver.u2ug.org [
u2-users-boun...@listserver.u2ug.org] on behalf of Wjhonson [
wjhon...@aol.com]
Sent: Thursday, 4 July 2013 7:31 AM
To: u2-users@listserver.u2ug.org; donr_w...@yahoo.com
Subject: Re: [U2] Running total

Can anyone explain this situation better.  I've only ever used the @ to
simplify a few I-descriptors.

I have a dict item SIZE that is just the LEN(@RECORD)

So in this thread we've seen two EVAL solutions to a running total

LIST VOC SIZE EVAL "@1+SIZE"
LIST VOC SIZE EVAL "SIZE + @2;@"

In the first example is the @1 just saving the "previous result of THIS
eval ?"

And then in the second example does the fact that SIZE is first in the
Eval, effectively *push* the accumulator into position two or something?
  So that's why you need @2 ?

And then what would be the meaning of ";@" at the end of that?

Pretty confusing stuff!






_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to