[ic] looping vs. query

Dean Hall hall@apt7.com
Sat, 28 Apr 2001 15:03:05 -0500

Thanks for your reply. I have more questions.

----- Original Message -----
From: "Jon Jensen" <jon@akopia.com>
To: <interchange-users@lists.akopia.com>
Sent: Saturday, April 28, 2001 02.18pm
Subject: Re: [ic] looping vs. query

> On Sat, 28 Apr 2001, Dean Hall wrote:
> > I'm trying to get every row in the DB with category_id of 2. Here's what
> > do:
> >
> > [loop prefix='prod' interpolate=1 search='fi=products/se=[scratch
> > category_id]/sf=category_id']
> > ...
> > [/loop]
> >
> > [scratch category_id] resolves to 2 in this case; the problem is that
> > getting a bunch of garbage when I reference [prod-code], [prod-field
> > or any other [prod-field xxx].
> I just tried your exact query (or as close as I can do without your data)
> on the default foundation demo products data and it worked fine:
> [set price]19.99[/set]
> [loop prefix='prod' search='fi=products/se=[scratch price]/sf=price']
> <p>
> Product SKU: [prod-code]<br>
> Name: [prod-field description]<br>
> Price: [prod-field price]
> </p>
> [/loop]
> Maybe there's some extremely subtle difference between your query and
> mine, but I don't see anything. The "interpolate=1" isn't needed, but the
> query still works with it.

Hmm, just doesn't work with mine. It gets all rows that match the criteria,
two that don't, and none of the fields (attributes) are correct -- the
[prod-field image] seems to contain the entire row from the products.txt
file, which is in the PIPE format while none of the other fields contain

> > I can't reset a scratch variable after it's been set (even with
> > [calc]$Scratch->counter++;return;[/calc])
> Try $Scratch->{counter}++ instead. $Scratch is a hashref. This is in the
> docs.

Yeah, that was just a type-o. I'm using the hashref. Still, it doesn't
change. Any ideas why?

What I'm trying now is:

[if explicit]
return (($Scratch->{counter}++ % 3) == 0);

This is only useful when I'm using the [query] tag instead of the [loop] tag
(with which I am using [loop-alternate 3]). If I get the [loop] stuff
working, I won't have to worry about it -- but I hate not knowing why it
won't work.

> I'm starting to get a little tired of the endless criticism of the
> documentation. I understand the frustration when something doesn't work as
> expected right away -- I experience that frequently. But many people have
> put a lot of work into Interchange, including the documentation, and it
> gets old hearing complaints. Once you figure out your specific problem
> maybe you can write it up in a FAQ for others.

I'm sure there has been a lot of criticism on the docs, and I'm sorry that
it annoys you, but it is well-deserved. I am not a horribly green developer;
I've used many different languages and development products, and the
documentation for IC is awful. It surely is extensive (i.e., large), and
that's part of the problem. You look up a tag in the tag docs, and it says
to look somewhere else. Where is this somewhere else? Who knows. The
documentation is too large to know for sure. Also, some of the most basic
stuff like what the hell those arguments to the loop tag are, is nowhere in
the docs -- this seems very, very important, and it's nowhere in the docs.