Akopia Akopia Services

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

Re: [mv] [if explicit][condition] troubles



******    message to minivend-users from hutch@cix.compulink.co.uk (Robert Hutchinson)     ******

In-Reply-To: <Pine.LNX.4.02.10002230117580.24923-100000@cedar.abhost.net>
In article <Pine.LNX.4.02.10002230117580.24923-100000@cedar.abhost.net>, 
mvend@cedar.abhost.net (abhost.net) wrote:

> ******    message to minivend-users from "abhost.net" 
> <mvend@cedar.abhost.net    ******
> 
> 
> Hi. I'm having some trouble getting 'if explicit' to do what I think it
> should do. If someone would help me out I'd be very grateful.
> 
> I've distilled my troubles down to a few test examples which hopefully
> illustrate what I'm trying to do. Each of these examples give the wrong
> result.
> 
> First, an if elsif else based on the value of a scratch varable...
> (I don't suppose that I can do 'condition interpolate=1' can I?)
> 
> <h3> example one </h3>
>  
> [set test]5[/set]test == '[scratch test]'
> [if explicit][condition]
>   my $test = '[scratch test]';
>   if ($test < 2) { return 0; }
>   elsif ($test < 4) { return 0; }
>   else { return 1; }
> [/condition]
> correct
> [else]
> incorrect
> [/else]
> [/if]
> 
> 
> Next, why is it that the start of line anchor '^' or the end of line
> anchor '$' mess up the regex matching?
> 
> <h3> example two </h3>
> 
> 
> [set test]test[/set]test == '[scratch test]'
> [if explicit][condition]
>   my $username = '[scratch test]';
>   if ($username =~ /^test$/) { return 1; }
>   return 0;
> [/condition]
> correct
> [else]
> incorrect
> [/else]
> [/if]
> 
> 
> 
> Finally, I might as well show this; it's what I really want to 
> accomplish
> anyway.  The first two examples I only came up with during my attempts 
> to
> get this to work.
> 
> the problem with this one is that the condition is always true... I
> imagine that if I could get example one and example two working this one
> would work as well...
> (I have a good imagination :)
> 
> <h3> what <i>really</i> I want to do </h3>
> 
> username == '[value mv_username]'
> [if explicit][condition]
>   my $username = '[value mv_username]';
>   if ($username =~ /^guest$/ || $username =~ /^$/) { return 0; }
>   else { return 1; }
> [/condition]
> $username =~ /^guest$/ || $username =~ /^$/
> [else]
> !($username =~ /^guest$/ || $username =~ /^$/)
> [/else]
> [/if]
> 
> Again, if there's anything that anyone can say to set me straight, I'll
> really appreciate it.  I'm using mv 3.14-5 with perl 5.005_03 on linux.
> 
> Thanks,
> 
> -- Jonathan
> 
> -
> 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
> 
> 
not too sure why your examples don't work, but this does:
[if explicit]
[condition]
return 1 if ('[item-data inventory qty]' < '1') and (__INVENTORY_ON__); 
[/condition]
        __OUTOFSTOCK__
[else]
        [if ordered [item-code]]
                __INBASKET__
        [else]
                &nbsp;<A HREF="[area order [item-code]]">__BUYBTN__</A>
        [/else]
        [/if]
[/else]
[/if]


Bye :-)=
hutch@cix.co.uk


-
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: