Repeat .. until

10 views
Skip to first unread message

Richard Torrens (lists)

unread,
Jun 24, 2020, 9:30:09 AM6/24/20
to colton-softw...@googlegroups.com
I am writing a custom function and have found ta repeat until loop that
causes PipeDream to crash irrevocably.

The function will eventualy write out an HTML table. Something I have done
before (e.g. http://stronged.torrens.org/man/PD - though they are PDream
files which will need filetyping). I'm baffled as to why this one crashes!

zip file attached

This with 4.57.01 (21-Mar-2020) on ARMX6 running 5.27 (09-Jun-20)

--
Richard Torrens.
http:/diy.Torrens.org/RO for PipeDream hints & tips
cf.zip,A91

Stuart Swales

unread,
Jun 26, 2020, 7:02:02 AM6/26/20
to colton-softw...@googlegroups.com
On 24/06/2020 13:32, Richard Torrens (lists) wrote:
> I am writing a custom function and have found ta repeat until loop that
> causes PipeDream to crash irrevocably.
>
> The function will eventualy write out an HTML table. Something I have done
> before (e.g. http://stronged.torrens.org/man/PD - though they are PDream
> files which will need filetyping). I'm baffled as to why this one crashes!
>
> zip file attached
>
> This with 4.57.01 (21-Mar-2020) on ARMX6 running 5.27 (09-Jun-20)
>

Thanks Richard

The crash is down to PipeDream not expecting an array as a parameter to
UNTIL().

You are getting this as you have only typed the guarding IF(counter<>0)
and ENDIF in your custom function as text not expressions, so the first
pass through the loop with counter=0 will cause the INDEX(array, 1,
counter) function to return an array containing all the values in column
1 of the array, as you see in B7. The UNTIL() then gets an array of each
value compared against "END" i.e. {FALSE, FALSE ... TRUE}. And then dies
horribly.

Fireworkz does handle this gracefully; I'll add it to the PipeDream bug
list.

Stuart's top tip: when doing array processing it's best to use loops
starting at one!

Cheers, Stuart

--
Stuart Swales

Richard Torrens (lists)

unread,
Jun 26, 2020, 7:20:39 AM6/26/20
to colton-softw...@googlegroups.com
In article <S885a18...@Torrens.org>,
Richard Torrens (lists) <Li...@Torrens.org> wrote:
> I am writing a custom function and have found a repeat until loop that
> causes PipeDream to crash irrevocably.

> The function will eventualy write out an HTML table. Something I have
> done before (e.g. http://stronged.torrens.org/man/PD - though they are
> PDream files which will need filetyping). I'm baffled as to why this one
> crashes!

Further examintion:

One oddity is that inside the loop, index([Features]names,1,counter)
is picking up the whole array of [Features]names

I only saw that wgeb I loaded the custom function into StronED.

Richard Torrens (lists)

unread,
Jun 29, 2020, 3:28:35 PM6/29/20
to colton-softw...@googlegroups.com
In article <1ea8a396-65b3-d68c...@gmail.com>,
I cut out the texted If loop.

But I found the construct

counter=0
repeat
do things
set_name("counter",counter+1)
lookup next
until(next="END")

crashed.

So I changed it to increment the counter first then test for:
until(index([Features]names,1,counter+1)="end")

Which gets over the problem of starting at 0. I hadn't expected that!

But I have sent you the final version - which has shown up a different bug
- an overflow somewhere.

I was wondering why the test ended up getting an array!

Thanks for keeping up the good work.

Long ago, when fireworkz was young, I was told tht Piprdream had better
programmability. I wonder if that's still true? But I'm used to PipeDream!

Stuart Swales

unread,
Jun 30, 2020, 6:56:36 AM6/30/20
to colton-softw...@googlegroups.com
I would do that as

counter = 1
repeat
lookup next [index(ref, 1, counter)]
if(next="END") then break
do things
increment counter
until(false)

Custom function-wise, very similar. Fireworkz can do additional things
like actioning functions on double clicks.

Scripting-wise, they are probably comparable.

--
Stuart Swales
Reply all
Reply to author
Forward
0 new messages