This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Output based on multiple combinations

 
K Robert
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
K Robert
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Build a string? Basic concept of string concatenation should do the trick.

Eric
 
K Robert
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
return it at the end, not in the if statements.

Eric
 
Liu Zhixiang
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
K Robert
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic