Row2Col II: Difference between revisions
From Pickwiki
Jump to navigationJump to search
mNo edit summary |
m link fix |
||
Line 1: | Line 1: | ||
HomePage>>SourceCode>>BasicSource>>Row2Col_II | HomePage>>SourceCode>>BasicSource>>[[Row2Col_II]] | ||
This utility can quickly transpose a dynamic array item's fields into values, and vice versa. | This utility can quickly transpose a dynamic array item's fields into values, and vice versa. | ||
Line 16: | Line 16: | ||
<pre> | <pre> | ||
function Row2Col(doc) | function [[Row2Col]](doc) | ||
*// Stuart Boydell Sept 2010 | *// Stuart Boydell Sept 2010 | ||
*// swap x & y axis of an array | *// swap x & y axis of an array |
Latest revision as of 23:48, 26 February 2015
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