[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] Can Anyone Get [if] to work in this case?
****** message to minivend-users from Hans-Joachim Leidinger <jojo@buchonline.net> ******
Ryan Hertz schrieb:
>
> ****** message to minivend-users from Ryan Hertz <rhertz@gyb.baits.com> ******
>
> At 01:32 PM 4/20/00 , you wrote:
> >****** message to minivend-users from "John C. Beima"
> ><jbeima@palb.com> ******
> >
> >G'Day Folks,
> >
> >I need to be able to do some conditional code, based on the content of a field
> >in one of my database.
>
> [snip]
>
> >But the [if data] doesn't seem to work with scratch variables. so if you go:
> >
> >[if data base="store" field="pg_[scratch page]_hd" key="[scratch outlet]" ==
> >1]
> >
> >or
> >
> >[if data base="store" field="pg_[scratch page]_hd" key="[scratch outlet]" ==
> >1]
> >
> >Nothing happens.
> >
> >Now if you go [if data store::pg_1_hd::100ADM == 1]
> >
> >It works.
> >
> >However [if data store::pg_[scratch page]_hd::[scratch outlet]] it doesn't.
> >
> >I have tried surrounding the scratch variables with quotes and inserting the
> >interpolation=1, neither works. I have also tried different variations of [if
> >explicit] as well, to no luck.
> >
> >Any ideas?
>
> Try interpolate=1 (if that was the problem) or perhaps (I forget if this is
> right) instead of using == 1, try eq "1"
>
> I have the most success with conditionals using this format:
> [if explicit]
> [condition]
> return 1 if $Safe{'scratch'}->{'outlet'} eq "11-20";
> return 0;
> [/condition]
> <P><I>This item does not contain salt. (11-20)
> [else]
> <P><I>Our soft plastics are salt-impregnated using a patented process.
> [/else]
> [/if]
>
> Or maybe this technique could help:
>
> [loop search="fi=store.asc/sf=pg_[scratch page]_hd/se=[scratch
> outlet]/ml=1/co=yes"]I found [scratch outlet] in pg_[scratch page]_hd[/loop]
>
> Basically, the conditionals in Minivend can be a bit tricky -- the best
> results will be found using Perl. :-)
Or another trick to do any conditional code working is,
1. Set anything to the scratch variable like
[set name="dummyvar" interpolate=1] [any MV tags] [/set]
2. make your conditional codes like
[if scratch dummyvar == 1] Yes!/No!-Answer [/if]
or
[if scratch dummyvar eq 1] Yes!/No!-Answer [/if]
or
[if scratch dummyvar =~ /1/] Yes!/No!-Answer [/if]
Or another methode is:
1. Set anything to the scratch variable like
[set name="dummyvarin" interpolate=1] [any MV tags] [/set]
2.
[perl arg=scratch]
my $out;
my $a = $Safe{'scratch'}->{'dummyvarin'};
if($a == 1){
the stuff for $a ist 1 to do anything and the result is in
$out!
$Safe{'scratch'}->{'dummyvarout'} = $out;
} else {
the stuff for $a ist not 1 to do anything and the result is
in $out!
$Safe{'scratch'}->{'dummyvarout'} = $out;
}
""; or $out; # ""; to print nothing and $out; to print the value of
$out;
[/perl]
If you are using "";, then you get the value of dummyvarout with
The value dummyvarout is : [scratch dummyvarout]<BR>
Regards,
Joachim
--
-------------Hans-Joachim Leidinger---------------------
-
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