Row2Col II: Difference between revisions
From Pickwiki
Jump to navigationJump to search
No edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
HomePage>>SourceCode>>BasicSource>>Row2Col_II | |||
This utility can quickly transpose a dynamic array item's fields into values, and vice versa. | |||
<pre> | |||
For example: | |||
0001: apple}banana}cantalope 0001: apple}111}red}0 | |||
0002: 111}222}333 becomes 0002: banana}222}green}1 | |||
0003: red}green}blue 0003: cantalope}333}blue}0 | |||
0004: 0}1}0 | |||
i.e. 4 fields with 3 values each becomes 3 fields with 4 values each. | |||
</pre> | |||
<pre> | |||
function Row2Col(doc) | function Row2Col(doc) | ||
*// swap x & y axis | *// Stuart Boydell Sept 2010 | ||
*// swap x & y axis of an array | |||
max = dcount(doc,@am) | max = dcount(doc,@am) | ||
newDoc = raise(doc<1>) | newDoc = raise(doc<1>) | ||
Line 9: | Line 27: | ||
return(doc) | return(doc) | ||
end | end | ||
</pre> |
Revision as of 03:59, 16 September 2010
HomePage>>SourceCode>>BasicSource>>Row2Col_II
This utility can quickly transpose a dynamic array item's fields into values, and vice versa.
For example: 0001: apple}banana}cantalope 0001: apple}111}red}0 0002: 111}222}333 becomes 0002: banana}222}green}1 0003: red}green}blue 0003: cantalope}333}blue}0 0004: 0}1}0 i.e. 4 fields with 3 values each becomes 3 fields with 4 values each.
function Row2Col(doc) *// Stuart Boydell Sept 2010 *// swap x & y axis of an array max = dcount(doc,@am) newDoc = raise(doc<1>) for i = 2 to max newDoc = splice(newDoc,char(222),raise(doc<i>)) next i doc = convert(char(222),@vm,newDoc) return(doc) end