Difference between revisions of "JoinText"

(Refined description, and added some 4.4.3 enhancements)
Line 34: Line 34:
 
= Examples =
 
= Examples =
  
Suppose ''A'' is the following array, indexed by ''J'':
+
Suppose ''A'' is the following array, indexed by ''J''
 
::{| border="1"
 
::{| border="1"
 
! J → || 1 || 2 || 3 || 4 || 5
 
! J → || 1 || 2 || 3 || 4 || 5
Line 44: Line 44:
 
Then:
 
Then:
 
<code>
 
<code>
:{| border="0" align="left"
+
:{| border="0"  
| [[JoinText]](A,J) || &rarr; || "onetwothreefourfive"
+
| [[JoinText]](A,J)  
 +
| &rarr; || "onetwothreefourfive"
 
|-
 
|-
| [[JoinText]](A,J,',') || &rarr; || "one,two,three,four,five"
+
| [[JoinText]](A,J,',')  
 +
| &rarr; || "one,two,three,four,five"
 
|-
 
|-
| [[JoinText]](A,J,", "," and ") || &rarr; || "one, two, three, four and five"
+
| [[JoinText]](A,J,", "," and ")  
 +
| &rarr; || "one, two, three, four and five"
 +
|-
 +
| [[JoinText]]([[Exp]](J^2),J,', ')
 +
| &rarr; || "2.718, 54.6, 8103, 8.886M, 72G"
 +
|}
 +
</code>
 +
 
 +
'''Treatment of Null'''.  Suppose ''B' is the following array indexed by ''J''
 +
::{| border="1"
 +
! J &rarr; || 1 || 2 || 3 || 4 || 5
 +
|-
 +
!
 +
| "one" || [[«null»]] || "three" || [[«null»]] || "five"
 +
|}
 +
 
 +
<code>
 +
:{| border="0"
 +
| [[JoinText]](B,J,",")
 +
| &rarr; || "one,three,five"
 +
|-
 +
| [[JoinText]](B,J,",",textForNull:"")
 +
| &rarr; || "one,,three,,five"
 +
|-
 +
| [[JoinText]](B,J,",",textForNull:"NULL")
 +
| &rarr; || "one,NULL,three,NULL,five"
 +
|-
 +
| [[JoinText]]([Null,Null,Null])
 +
| &rarr; || ""
 +
|-
 +
| [[JoinText]]([Null,Null,Null],default:null)
 +
| &rarr; || «null»
 +
|-
 +
| [[JoinText]]([])
 +
| &rarr; || ""
 +
|-
 +
| [[JoinText]]([],default:"empty")
 +
| &rarr; || "empty"
 
|}
 
|}
 
</code>
 
</code>

Revision as of 17:03, 4 July 2012


JoinText( A, I, separator, finalSeparator, default, textForNull )

Returns the elements of «A» (as text) concatenated along «I».

If any elements are numeric, they are converted to strings using the number format settings for the current node.

Null items are ignored, unless «textForNull» is specified.

Optional parameters

  • «separator»
: text inserted between each item.
  • «finalSeparator»
: Used instead of «separator» between the penultimate and final items.
  • «default»
: (new in 4.4.3) The result value when there are no items to be joined. E.g., when all items are Null.
  • «textForNull»
: (new in 4.4.3) When specified, Null items are not ignored, and the text provided is used.

Examples

Suppose A is the following array, indexed by J

J → 1 2 3 4 5
"one" "two" "three" "four" "five"

Then:

JoinText(A,J) "onetwothreefourfive"
JoinText(A,J,',') "one,two,three,four,five"
JoinText(A,J,", "," and ") "one, two, three, four and five"
JoinText(Exp(J^2),J,', ') "2.718, 54.6, 8103, 8.886M, 72G"

Treatment of Null. Suppose B' is the following array indexed by J

J → 1 2 3 4 5
"one" «null» "three" «null» "five"

JoinText(B,J,",") "one,three,five"
JoinText(B,J,",",textForNull:"") "one,,three,,five"
JoinText(B,J,",",textForNull:"NULL") "one,NULL,three,NULL,five"
JoinText([Null,Null,Null]) ""
JoinText([Null,Null,Null],default:null) «null»
JoinText([]) ""
JoinText([],default:"empty") "empty"

See Also

Comments


You are not allowed to post comments.