| Author |
Output based on multiple combinations
|
K Robert
Ranch Hand
Joined: May 16, 2003
Posts: 116
|
|
I have a funtion that checks the value of 3 array elements: I can get prodMessage to print based on this criteria, but if any of these conditions are true, I need to add "Business Partner 1", "Business Partner 2", "Business Partner 3", or any combination thereof to create examples such as: "Ordered by: Business Partner 3" "Ordered by: Business Partner 1, Business Partner 3" "Ordered by: Business Partner 1, Business Partner 2, Business Partner 3" Any help would be greatly appreciated.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
|
You should check for each flag one after another then (3 if blocks), and concatenate "Business Partner X" depending on each flag. Another method would be to use indexes to an array, instead of booleans.
|
[My Blog]
All roads lead to JavaRanch
|
 |
K Robert
Ranch Hand
Joined: May 16, 2003
Posts: 116
|
|
You should check for each flag one after another then (3 if blocks), and concatenate "Business Partner X" depending on each flag. Another method would be to use indexes to an array, instead of booleans.
So, if I read you right, something like this? How would I join them to prodMessage?
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Build a string? Basic concept of string concatenation should do the trick. Eric
|
 |
K Robert
Ranch Hand
Joined: May 16, 2003
Posts: 116
|
|
Yeah I understand "variable + variable + variable". Just didn't know if that was the case or not with the return values. As in:
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
return it at the end, not in the if statements. Eric
|
 |
Liu Zhixiang
Ranch Hand
Joined: Aug 12, 2006
Posts: 32
|
|
if ((busPart1 == "ordered" ;) || (busPart2 == "ordered" ;) || (busPart3 == "ordered" ;) ) { var bp1=(busPart1 == "ordered"?"Business Partner 1":"" ;) ; var bp2=(busPart2 == "ordered"?"Business Partner 2":"" ;) ; var bp3=(busPart3 == "ordered"?"Business Partner 3":"" ;) ; var results="Ordered by: "+bp1+bp2+bp3; return results; } OR var results = (busPart1 == "ordered"?"Business Partner 1":"" ;) +(busPart2 == "ordered"?"Business Partner 2":"" ;) +(busPart3 == "ordered"?"Business Partner 3":"" ;) ; if(results!="" ;) {return results}; [ September 20, 2006: Message edited by: Liu Zhixiang ]
|
I Think Therefore I Am
|
 |
K Robert
Ranch Hand
Joined: May 16, 2003
Posts: 116
|
|
|
Thanks for the help.
|
 |
 |
|
|
subject: Output based on multiple combinations
|
|
|