Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Need to remove a brand from later question if it is aware but not used in last months

I am using the given below Perl script but facing with script error. I have tried to change the parentheses scheme but could not succeed.

Begin Unverified Perl
if(VALUE("M1_c1")==1 && VALUE("M7_r1_c1")==0) ||
(VALUE("M1_c1")==7 && VALUE("M7_r7_c1")==0) ||
(VALUE("M1_c1")==8 && VALUE("M7_r8_c1")==0) ||
(VALUE("M2_r1_c1")==1 && VALUE("M7_r1_c1")==0) ||
(VALUE("M2_r7_c1")==1 && VALUE("M7_r7_c1")==0) ||
(VALUE("M2_r8_c1")==1 && VALUE("M7_r8_c1")==0) ||
(VALUE("M3_r1_c1")==1 && VALUE("M7_r1_c1")==0) ||
{
ADD("MotherBrandList",1);
}
if(VALUE("M1_c1")==10 && VALUE("M7_r10_c1")==0) ||
(VALUE("M1_c1")==12 && VALUE("M7_r12_c1")==0) ||
(VALUE("M1_c1")==13 && VALUE("M7_r13_c1")==0) ||
(VALUE("M2_r10_c1")==1 && VALUE("M7_r10_c1")==0) ||
(VALUE("M2_r12_c1")==1 && VALUE("M7_r12_c1")==0) ||
(VALUE("M2_r13_c1")==1 && VALUE("M7_r13_c1")==0) ||
(VALUE("M3_r10_c1")==1 && VALUE("M7_r10_c1")==0) ||
{
ADD("MotherBrandList",2);
}
end unverified

I am using the similar script without && and it is working but in the other question i have different need.

This script is working without && in the other questions:

Begin Unverified Perl
if((VALUE("M1_c1")==1) || (VALUE("M1_c1")==7) || (VALUE("M1_c1")==8) || (VALUE("M2_r1_c1")==1) || (VALUE("M2_r7_c1")==1) || (VALUE("M2_r8_c1")==1) || (VALUE("M3_r1_c1")==1) || (VALUE("M3_r7_c1")==1) || (VALUE("M3_r8_c1")==1))
{
ADD("MotherBrandList",1);
}
if((VALUE("M1_c1")==10) || (VALUE("M1_c1")==12) || (VALUE("M1_c1")==13) || (VALUE("M2_r10_c1")==1) || (VALUE("M2_r12_c1")==1) || (VALUE("M2_r13_c1")==1) || (VALUE("M3_r10_c1")==1) || (VALUE("M3_r12_c1")==1) || (VALUE("M3_r13_c1")==1))
{
ADD("MotherBrandList",2);
{
ADD("MotherBrandList",2);
}
end unverified

Can anyone guide me please on this.

Thanks and best regards
asked Sep 3, 2014 by Rashid (230 points)

1 Answer

0 votes
You have missed starting and closing parenthesis. Please copy below code, it should work. Also had extra or at the end of if condition.

Begin Unverified Perl
if((VALUE("M1_c1")==1 && VALUE("M7_r1_c1")==0) || (VALUE("M1_c1")==7 && VALUE("M7_r7_c1")==0) || (VALUE("M1_c1")==8 && VALUE("M7_r8_c1")==0) || (VALUE("M2_r1_c1")==1 && VALUE("M7_r1_c1")==0) || (VALUE("M2_r7_c1")==1 && VALUE("M7_r7_c1")==0) || (VALUE("M2_r8_c1")==1 && VALUE("M7_r8_c1")==0) || (VALUE("M3_r1_c1")==1 && VALUE("M7_r1_c1")==0))
{
ADD("MotherBrandList",1);
}
if((VALUE("M1_c1")==10 && VALUE("M7_r10_c1")==0) || (VALUE("M1_c1")==12 && VALUE("M7_r12_c1")==0) || (VALUE("M1_c1")==13 && VALUE("M7_r13_c1")==0) || (VALUE("M2_r10_c1")==1 && VALUE("M7_r10_c1")==0) || (VALUE("M2_r12_c1")==1 && VALUE("M7_r12_c1")==0) || (VALUE("M2_r13_c1")==1 && VALUE("M7_r13_c1")==0) || (VALUE("M3_r10_c1")==1 && VALUE("M7_r10_c1")==0))
{
ADD("MotherBrandList",2);
}
End Unverified
answered Sep 3, 2014 by Rajesh Rana Gold (23,330 points)
Thank you very much for you help Rajesh. the code is working :)
Hi Rajesh, Can you please guide if I can add any additional brands from the same parent list in the given below format:

Begin Unverified Perl
if((VALUE("M4_r1_c1")==1) || (VALUE("M4_r7_c1")==1) || (VALUE("M4_r8_c1")==1))
{
ADD("MotherBrandList",1);
}
if((VALUE("M4_r10_c1")==1) || (VALUE("M4_r12_c1")==1) || (VALUE("M4_r13_c1")==1))
{
ADD("MotherBrandList",2);
}
if((VALUE("M4_r15_c1")==1) || (VALUE("M4_r20_c1")==1) || (VALUE("M4_r21_c1")==1))
{
ADD("MotherBrandList",3);
}
if((VALUE("M4_r23_c1")==1) || (VALUE("M4_r28_c1")==1) || (VALUE("M4_r29_c1")==1))
{
ADD("MotherBrandList",4);
}
if((VALUE("M4_r31_c1")==1) || (VALUE("M4_r32_c1")==1))
{
ADD("MotherBrandList",5);
}
if((VALUE("M4_r35_c1")==1) || (VALUE("M4_r36_c1")==1) || (VALUE("M4_r37_c1")==1))
{
ADD("MotherBrandList",6);
}
if((VALUE("M4_r43_c1")==1) || (VALUE("M4_r44_c1")==1) || (VALUE("M4_r45_c1")==1))
{
ADD("MotherBrandList",7);
}
{
ADD("MotherBrandList",8);
}
{
ADD("MotherBrandList",9);
}
{
ADD("MotherBrandList",10);
}
{
ADD("MotherBrandList",11);
}
{
ADD("MotherBrandList",12);
}
{
ADD("MotherBrandList",13);
}
{
ADD("MotherBrandList",14);
}
{
ADD("MotherBrandList",15);
}   
{
ADD("MotherBrandList",16);
}
{
ADD("MotherBrandList",19);
}
end unverified

Please guide.

Thanks and best regards
Change the bottom part of your code (the final if statement) to ...
if((VALUE("M4_r43_c1")==1) || (VALUE("M4_r44_c1")==1) || (VALUE("M4_r45_c1")==1))
{
ADD("MotherBrandList",7,16);
ADD("MotherBrandList",19);
}
And change your "End Unverified".
...