Groups | Search | Server Info | Login | Register


Groups > comp.sys.acorn.apps > #19413

Pipedream lookup error in custom function

From Harriet Bazley <harriet@bazleyfamily.co.uk>
Newsgroups comp.sys.acorn.apps
Subject Pipedream lookup error in custom function
Date 2025-04-11 20:46 +0100
Organization A noiseless patient Spider
Message-ID <50d0090c5c.harriet@bazleyfamily.co.uk> (permalink)

Show all headers | View raw


I have a fairly basic Pipedream custom function that adds up the total
of all the items that match an arbitrary list of categories (items of
expenditure that come under the heading of 'food').  But it gives an
error if any of the categories in the list are not found in the input,
because the lookup function fails.

Typical usage:
edibles(array1,array2), where array 1 and array2 are non-consecutive
database columns containing categories of expenditure (e.g. Transport,
Grocery, Clothes) and totals spent under those categories.  I just want
to be able to add up the subtotal of the amount spent on edible items
specifically.

But how do I 'blank' the input so that a non-existent category is
counted as having a value of zero, rather than throwing an error?
Currently I have to manually add an extra row to the input arrays, e.g.
"Dairy", 0, in order to suppress the error when in occurs.

I feel that it ought to be possible to have some kind of 'if' option
that would return zero if the lookup fails, but I can't work out a way
of doing it.)

=================================

Add up the total value of all the entries in array 2 which correspond to 
entries in array 1 that match one of the text values specified in this 
function. 
------------------------------------------------------------------------
...function("edibles","categories:array","prices:array")
...lookup(C7,@categories,@prices)		Dairy
...lookup(C8,@categories,@prices)		Greengrocery
...lookup(C9,@categories,@prices)		Grocery
...lookup(C10,@categories,@prices)		Meat
...result(sum(A7A10))


-- 
Harriet Bazley                     ==  Loyaulte me lie ==

It is better to have loved and lost than just to have lost.

Back to comp.sys.acorn.apps | Previous | NextNext in thread | Find similar


Thread

Pipedream lookup error in custom function Harriet Bazley <harriet@bazleyfamily.co.uk> - 2025-04-11 20:46 +0100
  Re: Pipedream lookup error in custom function "Richard Torrens (News) <News@Torrens.org> - 2025-04-13 11:42 +0100
    Re: Pipedream lookup error in custom function Harriet Bazley <harriet@bazleyfamily.co.uk> - 2025-04-13 18:14 +0100

csiph-web