Akopia Akopia Services

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

Re: [mv] if perl question



******    message to minivend-users from Mike Heins <mikeh@minivend.com>     ******

Quoting Adam Kett (adam@opusvl.com):
> ******    message to minivend-users from Adam Kett <adam@opusvl.com>     ******
> 
> Hello 
> just wondering if any one can help with a little if question
> 
> does any one know how can do the following
> 
> [if value somevar == 2 or 3]
> 
> 
> or possibly
> 
> [if explicit]
> 
>   [condition]
>         $somevar = '[value somevar_from_page]';
>         return 1 if $somevar == 2;
>         return 1 if $somevar == 1;            
>         return 0;
>   [/condition]
> 
>         true 
> 	somevar_from_page == 1 or 2
>   [else]     
>         false
> 	somevar_from_page not equal 1 or 2
>   [/else]
> 
> [/if]
> 

Probably easier is:

[if value somevar_from_page =~ /^(1|2)$/] 
	True.
[else]
	False.
[/else]
[/if]

But if you want that C-ish numerical comparison, you can do:

[if test=explicit compare=`
			return 1 if $Values->{somevar_from_page} == 2;
			return 1 if $Values->{somevar_from_page} == 1;
			return 0;
		 ` ]
	True.
[else]
	False.
[/else]
[/if]

Note that those are backticks and not single quotes. The above is the same
as:

[if test=explicit compare="[calc]
			return 1 if $Values->{somevar_from_page} == 2;
			return 1 if $Values->{somevar_from_page} == 1;
			return 0;
			[/calc]" ]
	True.
[else]
	False.
[/else]
[/if]
-- 
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>

Friends don't let friends use Outlook. -- Bob Blaylock
-
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: