MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

RE: Using variables in [data ...] statement





You problem seems to be more that you are trying to test for a null value than that of returning a value in the data element.  Why not use Minivend's very useful built in functions to accomplish this instead of embedded perl? The following code shows how to do this in order to accomplish a neato-keano feature, alternating background colors for a product listing.


Try a variation of this:

[comment}
Put this outside of your main loop
This set the "count" variable to a null value
[/comment]
[set count][/set]


[comment]
Put this in place of the table tag you will be using
for your display, inside the main loop.
[/comment]

[if scratch count]
<TABLE BORDER="0" WIDTH="600" BGCOLOR="#FFFFFF">
[set count][/set]
[else]
<TABLE BORDER="0" WIDTH="600" BGCOLOR="[var BARBG]">
[set count]1[/set]
[/else]
[/if]

[comment]
notice that the statement [if scratch count] actually
tests for any non-null value, if the value of count is
any non-null value, the color white is used as the background
and the value is set to a null with [set count][/set]
otherwise the color light beige is used as the background
and the value of count is set to a non-null value,
in this case the number 1 with [set count]1[/set] however
you could set it to anything you wish
[/comment]


Your variation might be:

[if data songs name $upc]
blah
[else]
blahsey blah
[/else]
[/if]

vandy
Keeping the GNU spririt alive with neeto-keeno code examples!

-----Original Message-----
From: Mike Lerley [mailto:mike@bfent.com]
Sent: Friday, April 23, 1999 9:19 AM
To: minivend-users@minivend.com
Subject: Re: Using variables in [data ...] statement


******    message to minivend-users from Mike Lerley <mike@bfent.com>     ******

Ahhh.... I understand now. 
However:  I think this is a related question.

Trying to determine whether or not [data...] returns a value.  Snippet:

my $sname;
$sname="[data songs name $upc]";

if(length($sname)>0) {
        blah;
}

But upon inspection, length($data) ALWAYS returns 33.  Doesn't matter
what's in there.  $data always contains the correct stuff (i.e. song
name or nothing if not found), but length() never returns the length! 

On the other hand:

my $hi;
$hi="1234567";
length($hi);

returns 7.

Argh!  Please help.  I don't have to use length() to determine results;
if anyone has better ideas I'm quite open.  Thanks...

-mike


Frank Miedreich wrote:
> This works exactly as advertised:
>
> 1st step: minivend tag Interpolation
> 2nd step: Execution of perl code
>
> This means that ALL your minivend tags in your perl code are interpolated,
> before any perl will be executed, thus the code fails during the
> interpolation step.
>
> You could do:
> [data base="albums" field="small" key="[perl interpolate=1]
> $sku="12345";
> $sku;
> [/perl]"]
>
> or:
> [perl]
> $sku="12345";
> "\[data albums small $sku\]";
> [/perl]

--
Mike Lerley, Technical Systems Administrator
Goold Health Systems
24 Stone Street
Augusta, ME 04330
Email mike@bfent.com
Phone (207) 622-3298
Fax   (207) 623-5125
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: