[ic] ifs with scratch variables

Daniel Davenport DDavenport at newagedigital.com
Tue Nov 21 14:56:39 EST 2006

> -----Original Message-----
> From: interchange-users-bounces at icdevgroup.org
> bounces at icdevgroup.org] On Behalf Of Bob Puff
> Sent: Sunday, November 19, 2006 2:53 PM
> To: interchange-users at icdevgroup.org
> Subject: [ic] ifs with scratch variables
> Hi Group,
> I was recently messing around with the shipmode page from a recent
> install.
> Using a IC 5.2 engine, I tried:
> [tmp bobshp][shipping mode="[loop-code]"][/tmp]
> ..within the listing of shipping modes.  It does indeed "take", as I
> say
> something like:
> Cost: [scratch bobshp]
> and it prints out nicely.  However, I can't seem to get this to work:
> [if scratch bobshp eq "$0.01"] ...

That doesn't work as is on 5.2.0.
Without the quotes, though, it apparently works fine.  Seems that last
part is taken as what to compare -- quotes and all.

Seems to work either way on 5.3.1.

> I've tried a few different things, like:
> [if type=explicit compare='[scratch bobshp] eq "$0.01"']

That won't work.  I see two problems:
- Double quotes around your price.  $0 is special to perl; on most
systems, it's the name of the running program.  And that's assuming the
Safe module would even let that info through, which it appears not to.
Double quotes tell perl to interpolate variables in the string, so the
string you're actually comparing likely ends up as ".01".
- No quotes around your scratch tag.  In perl, $0.01 ends up parsed like
($0 . 1), which returns "1" on my machines.

If you want to try the explicit way, try this:
[if type=explicit compare="'[scratch bobshp]' eq '$0.01'"]
Or, maybe better if you really want to do the explicit thing:
[if type=explicit compare="$Scratch->{bobshp} eq '$0.01'"]

Or, if you were just trying to use named parameters for your [if...]:
[if type=scratch term=bobshp op=eq compare="$0.01"]

> ...but can't seem to get it to work.  And this is when it is
> "$0.01" in the simple printing of [scratch bobshp].  What am I doing
> wrong?

Might want to temporarily put some kind of delimiters around the output
of the shipping rate, so you can see whether there's any space that
shouldn't be there.

More information about the interchange-users mailing list