<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pickwiki.org/index.php?action=history&amp;feed=atom&amp;title=Row2Col</id>
	<title>Row2Col - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pickwiki.org/index.php?action=history&amp;feed=atom&amp;title=Row2Col"/>
	<link rel="alternate" type="text/html" href="https://pickwiki.org/index.php?title=Row2Col&amp;action=history"/>
	<updated>2026-04-28T22:11:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://pickwiki.org/index.php?title=Row2Col&amp;diff=2552&amp;oldid=prev</id>
		<title>TonyG at 21:44, 15 May 2015</title>
		<link rel="alternate" type="text/html" href="https://pickwiki.org/index.php?title=Row2Col&amp;diff=2552&amp;oldid=prev"/>
		<updated>2015-05-15T21:44:31Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:44, 15 May 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;HomePage&amp;gt;&amp;gt;SourceCode&amp;gt;&amp;gt;BasicSource&amp;gt;&amp;gt;[[Row2Col]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;HomePage&amp;gt;&amp;gt;SourceCode&amp;gt;&amp;gt;BasicSource&amp;gt;&amp;gt;[[Row2Col]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This utility can transpose a dynamic array item&#039;s fields into values, and vice versa.  I originally wrote it for &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/del&gt;AccuTerm&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/nowiki&amp;gt; &lt;/del&gt;GUI programming, where I needed to load records into grid controls.  Calling the utility a second time on the same variable will transpose it back to its original &quot;shape&quot;; in order to do this accurately, all fields must contain the same number of values.  It&#039;s pretty fast on large records too, since it only passes through the original item a few times (instead of extracting and replacing hundreds of fields and values.)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This utility can transpose a dynamic array item&#039;s fields into values, and vice versa.  I originally wrote it for &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[&lt;/ins&gt;AccuTerm&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] &lt;/ins&gt;GUI programming, where I needed to load records into grid controls.  Calling the utility a second time on the same variable will transpose it back to its original &quot;shape&quot;; in order to do this accurately, all fields must contain the same number of values.  It&#039;s pretty fast on large records too, since it only passes through the original item a few times (instead of extracting and replacing hundreds of fields and values.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l14&quot;&gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;2008-01-18 by [[Rex Gozar]]&amp;lt;br&amp;gt;A discussion on comp.databases.pick suggested some techniques to make this program faster.   The new 1.2 revision takes advantage of &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Universe&lt;/del&gt;&#039;s internal optimizations to make it 6x faster.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;2008-01-18 by [[Rex Gozar]]&amp;lt;br&amp;gt;A discussion on &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Community|&lt;/ins&gt;comp.databases.pick&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] &lt;/ins&gt;suggested some techniques to make this program faster.   The new 1.2 revision takes advantage of &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[UniVerse]]&lt;/ins&gt;&#039;s internal optimizations to make it 6x faster.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The first optimization was to take advantage of Universe&amp;#039;s ability to quickly traverse from field to field within a string.  (Note that traversing values is NOT optimized in Universe.)  DCOUNT&amp;#039;ing the fields to check the value counts cut a significant amount of time off the processing.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The first optimization was to take advantage of Universe&amp;#039;s ability to quickly traverse from field to field within a string.  (Note that traversing values is NOT optimized in Universe.)  DCOUNT&amp;#039;ing the fields to check the value counts cut a significant amount of time off the processing.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>TonyG</name></author>
	</entry>
	<entry>
		<id>https://pickwiki.org/index.php?title=Row2Col&amp;diff=2191&amp;oldid=prev</id>
		<title>Conversion script: link fix</title>
		<link rel="alternate" type="text/html" href="https://pickwiki.org/index.php?title=Row2Col&amp;diff=2191&amp;oldid=prev"/>
		<updated>2015-02-26T23:48:55Z</updated>

		<summary type="html">&lt;p&gt;link fix&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;HomePage&amp;gt;&amp;gt;SourceCode&amp;gt;&amp;gt;BasicSource&amp;gt;&amp;gt;[[Row2Col]]&lt;br /&gt;
&lt;br /&gt;
This utility can transpose a dynamic array item&amp;#039;s fields into values, and vice versa.  I originally wrote it for &amp;lt;nowiki&amp;gt;AccuTerm&amp;lt;/nowiki&amp;gt; GUI programming, where I needed to load records into grid controls.  Calling the utility a second time on the same variable will transpose it back to its original &amp;quot;shape&amp;quot;; in order to do this accurately, all fields must contain the same number of values.  It&amp;#039;s pretty fast on large records too, since it only passes through the original item a few times (instead of extracting and replacing hundreds of fields and values.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 For example:&lt;br /&gt;
 &lt;br /&gt;
  0001: apple}banana}cantalope                    0001: apple}111}red}0&lt;br /&gt;
  0002: 111}222}333                  becomes      0002: banana}222}green}1&lt;br /&gt;
  0003: red}green}blue                            0003: cantalope}333}blue}0&lt;br /&gt;
  0004: 0}1}0&lt;br /&gt;
&lt;br /&gt;
i.e. 4 fields with 3 values each becomes 3 fields with 4 values each.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2008-01-18 by [[Rex Gozar]]&amp;lt;br&amp;gt;A discussion on comp.databases.pick suggested some techniques to make this program faster.   The new 1.2 revision takes advantage of Universe&amp;#039;s internal optimizations to make it 6x faster.&lt;br /&gt;
&lt;br /&gt;
The first optimization was to take advantage of Universe&amp;#039;s ability to quickly traverse from field to field within a string.  (Note that traversing values is NOT optimized in Universe.)  DCOUNT&amp;#039;ing the fields to check the value counts cut a significant amount of time off the processing.&lt;br /&gt;
&lt;br /&gt;
The second optimization uses Universe&amp;#039;s REMOVE function to load the values into a dimensioned array.  This function traverses both fields and values quickly, and also cut processing time.&lt;br /&gt;
&lt;br /&gt;
The discussion (and benchmarks) leads me to conclude that for small data sets (under 100KB and under 1000 values), simpler home-grown solutions are usually adequate. [[ROW2COL]] now has good performance for smaller data sets, and also scales well to large data sets (over 500KB and over 10,000 values).&lt;br /&gt;
&lt;br /&gt;
My benchmark results in milliseconds:&lt;br /&gt;
&amp;lt;br&amp;gt;70KB variable with 1,000 fields or values: 22ms (new) vs. 140ms (old)&lt;br /&gt;
&amp;lt;br&amp;gt;704KB variable with 10,000 fields or values: 225ms (new) vs. 1428ms (old)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      SUBROUTINE [[ROW2COL]](ITEM)&lt;br /&gt;
******&lt;br /&gt;
* [[ROW2COL]]  $Revision: 1.2 $&lt;br /&gt;
* Transpose table data &amp;quot;rows&amp;quot; (fields) to &amp;quot;columns&amp;quot; (values).&lt;br /&gt;
* Copyright (C) 2004 Rex Gozar&lt;br /&gt;
*&lt;br /&gt;
* This library is free software; you can redistribute it and/or&lt;br /&gt;
* modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
* License as published by the Free Software Foundation; either&lt;br /&gt;
* version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
*&lt;br /&gt;
* This library is distributed in the hope that it will be useful,&lt;br /&gt;
* but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
* Lesser General Public License for more details.&lt;br /&gt;
*&lt;br /&gt;
* You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
* License along with this library; if not, write to the Free Software&lt;br /&gt;
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
* http://www.gnu.org/licenses/lgpl.html&lt;br /&gt;
*&lt;br /&gt;
* Rex Gozar&lt;br /&gt;
* rkgozar@juno.com&lt;br /&gt;
******&lt;br /&gt;
$OPTIONS DEFAULT&lt;br /&gt;
***&lt;br /&gt;
* Find the maximum number of fields and the maximum&lt;br /&gt;
* number of values per field.  Note that all fields&lt;br /&gt;
* must have the same number of values; otherwise,&lt;br /&gt;
* additional delimiters would need to be added as&lt;br /&gt;
* placeholders and the resulting item could not be&lt;br /&gt;
* &amp;quot;flipped&amp;quot; back into its original form.&lt;br /&gt;
***&lt;br /&gt;
      ITEMLEN = LEN(ITEM)&lt;br /&gt;
      FMAX = DCOUNT(ITEM, @FM)&lt;br /&gt;
      VMAX = DCOUNT(ITEM&amp;lt;1&amp;gt;, @VM)&lt;br /&gt;
      FOR FMC = 2 TO FMAX&lt;br /&gt;
         VMC = DCOUNT(ITEM&amp;lt;FMC&amp;gt;, @VM)&lt;br /&gt;
         IF VMC NE VMAX THEN&lt;br /&gt;
            ABORTM &amp;quot;FIELDS DO NOT HAVE THE SAME VALUE COUNT&amp;quot;&lt;br /&gt;
         END&lt;br /&gt;
      NEXT FMC&lt;br /&gt;
***&lt;br /&gt;
* Extract the elements and load them into an array.&lt;br /&gt;
* This should be faster than &amp;lt;&amp;gt; extraction on large items.&lt;br /&gt;
***&lt;br /&gt;
      DIM ARRAY(FMAX,VMAX)&lt;br /&gt;
      ITEM = ITEM&lt;br /&gt;
      TEXT = &amp;#039;&amp;#039;&lt;br /&gt;
      FMC = 1&lt;br /&gt;
      VMC = 1&lt;br /&gt;
      LOOP&lt;br /&gt;
         TEXT := REMOVE(ITEM, MORE)&lt;br /&gt;
         DELIM = (IF MORE THEN CHAR(256-MORE) ELSE &amp;#039;&amp;#039;)&lt;br /&gt;
         BEGIN CASE&lt;br /&gt;
            CASE DELIM EQ @VM&lt;br /&gt;
               ARRAY(FMC,VMC) = TEXT&lt;br /&gt;
               VMC += 1&lt;br /&gt;
               TEXT = &amp;#039;&amp;#039;&lt;br /&gt;
            CASE DELIM EQ @FM OR DELIM EQ &amp;#039;&amp;#039;&lt;br /&gt;
               ARRAY(FMC,VMC) = TEXT&lt;br /&gt;
               FMC += 1&lt;br /&gt;
               VMC = 1&lt;br /&gt;
               TEXT = &amp;#039;&amp;#039;&lt;br /&gt;
            CASE @TRUE&lt;br /&gt;
               TEXT := DELIM&lt;br /&gt;
         END CASE&lt;br /&gt;
      WHILE MORE REPEAT&lt;br /&gt;
***&lt;br /&gt;
* Build the new item so values are fields and fields&lt;br /&gt;
* are values.&lt;br /&gt;
***&lt;br /&gt;
      BUFFER = SPACE(ITEMLEN)&lt;br /&gt;
      BUFPOS = 1&lt;br /&gt;
      EQU APPEND$TEXT LIT &amp;quot;BUFFER[BUFPOS,LEN(TEXT)] = TEXT ; BUFPOS += LEN(TEXT)&amp;quot;&lt;br /&gt;
      FOR VMC = 1 TO VMAX&lt;br /&gt;
         IF VMC # 1 THEN&lt;br /&gt;
            TEXT = @FM&lt;br /&gt;
            APPEND$TEXT&lt;br /&gt;
         END&lt;br /&gt;
         FOR FMC = 1 TO FMAX&lt;br /&gt;
            IF FMC # 1 THEN&lt;br /&gt;
               TEXT = @VM&lt;br /&gt;
               APPEND$TEXT&lt;br /&gt;
            END&lt;br /&gt;
            TEXT = ARRAY(FMC,VMC)&lt;br /&gt;
            APPEND$TEXT&lt;br /&gt;
         NEXT FMC&lt;br /&gt;
      NEXT VMC&lt;br /&gt;
***&lt;br /&gt;
* Done.&lt;br /&gt;
***&lt;br /&gt;
      ITEM = BUFFER&lt;br /&gt;
      RETURN&lt;br /&gt;
   END&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The older 1.1 revision for comparison.  I don&amp;#039;t think it contains any Universe-specific functions or statements.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      SUBROUTINE [[ROW2COL]](ITEM)&lt;br /&gt;
******&lt;br /&gt;
* [[ROW2COL]]  $Revision: 1.1 $&lt;br /&gt;
* Transpose table data &amp;quot;rows&amp;quot; (fields) to &amp;quot;columns&amp;quot; (values).&lt;br /&gt;
* Copyright (C) 2004 Rex Gozar&lt;br /&gt;
*&lt;br /&gt;
* This library is free software; you can redistribute it and/or&lt;br /&gt;
* modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
* License as published by the Free Software Foundation; either&lt;br /&gt;
* version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
*&lt;br /&gt;
* This library is distributed in the hope that it will be useful,&lt;br /&gt;
* but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
* Lesser General Public License for more details.&lt;br /&gt;
*&lt;br /&gt;
* You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
* License along with this library; if not, write to the Free Software&lt;br /&gt;
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA&lt;br /&gt;
* http://www.gnu.org/licenses/lgpl.html&lt;br /&gt;
*&lt;br /&gt;
* Rex Gozar&lt;br /&gt;
* rkgozar@juno.com&lt;br /&gt;
******&lt;br /&gt;
$OPTIONS DEFAULT&lt;br /&gt;
***&lt;br /&gt;
* Find the maximum number of fields and the maximum&lt;br /&gt;
* number of values per field.  Note that all fields&lt;br /&gt;
* must have the same number of values; otherwise,&lt;br /&gt;
* additional delimiters would need to be added as&lt;br /&gt;
* placeholders and the resulting item could not be&lt;br /&gt;
* &amp;quot;flipped&amp;quot; back into its original form.&lt;br /&gt;
***&lt;br /&gt;
      ITEMLEN = LEN(ITEM)&lt;br /&gt;
      FMC = 1&lt;br /&gt;
      VMC = 1&lt;br /&gt;
      VMAX = 0&lt;br /&gt;
      J = 0&lt;br /&gt;
      LOOP&lt;br /&gt;
         J += 1&lt;br /&gt;
         C = ITEM[J,1]&lt;br /&gt;
         BEGIN CASE&lt;br /&gt;
            CASE C = @VM&lt;br /&gt;
               VMC += 1&lt;br /&gt;
            CASE C = @FM OR C = &amp;#039;&amp;#039;&lt;br /&gt;
               IF FMC = 1 THEN&lt;br /&gt;
                  VMAX = VMC&lt;br /&gt;
               END ELSE&lt;br /&gt;
                  IF VMC # VMAX THEN&lt;br /&gt;
                     ABORTM &amp;quot;FIELDS DO NOT HAVE THE SAME VALUE COUNT&amp;quot;&lt;br /&gt;
                  END&lt;br /&gt;
               END&lt;br /&gt;
               IF C = @FM THEN&lt;br /&gt;
                  FMC += 1&lt;br /&gt;
               END&lt;br /&gt;
               VMC = 1&lt;br /&gt;
         END CASE&lt;br /&gt;
      WHILE C # &amp;#039;&amp;#039; REPEAT&lt;br /&gt;
      FMAX = FMC&lt;br /&gt;
***&lt;br /&gt;
* Extract the elements and load them into an array.&lt;br /&gt;
* This should be faster than &amp;lt;&amp;gt; extraction on large items.&lt;br /&gt;
***&lt;br /&gt;
      DIM ARRAY(FMAX,VMAX)&lt;br /&gt;
      MAT ARRAY = &amp;#039;&amp;#039;&lt;br /&gt;
      FMC = 1&lt;br /&gt;
      VMC = 1&lt;br /&gt;
      TEXTPOS = 1&lt;br /&gt;
      TEXTLEN = 0&lt;br /&gt;
      J = 0&lt;br /&gt;
      LOOP&lt;br /&gt;
         J += 1&lt;br /&gt;
         C = ITEM[J,1]&lt;br /&gt;
         BEGIN CASE&lt;br /&gt;
            CASE C = @VM&lt;br /&gt;
               ARRAY(FMC,VMC) = ITEM[TEXTPOS,TEXTLEN]&lt;br /&gt;
               TEXTPOS = J + 1&lt;br /&gt;
               TEXTLEN = 0&lt;br /&gt;
               VMC += 1&lt;br /&gt;
            CASE C = @FM OR C = &amp;#039;&amp;#039;&lt;br /&gt;
               ARRAY(FMC,VMC) = ITEM[TEXTPOS,TEXTLEN]&lt;br /&gt;
               TEXTPOS = J + 1&lt;br /&gt;
               TEXTLEN = 0&lt;br /&gt;
               FMC += 1&lt;br /&gt;
               VMC = 1&lt;br /&gt;
            CASE 1&lt;br /&gt;
               TEXTLEN += 1&lt;br /&gt;
         END CASE&lt;br /&gt;
      WHILE C # &amp;#039;&amp;#039; REPEAT&lt;br /&gt;
***&lt;br /&gt;
* Build the new item so values are fields and fields&lt;br /&gt;
* are values.&lt;br /&gt;
***&lt;br /&gt;
      BUFFER = SPACE(ITEMLEN)&lt;br /&gt;
      BUFPOS = 1&lt;br /&gt;
      FOR VMC = 1 TO VMAX&lt;br /&gt;
         IF VMC # 1 THEN&lt;br /&gt;
            TEXTLEN = 1&lt;br /&gt;
            BUFFER[BUFPOS,TEXTLEN] = @FM&lt;br /&gt;
            BUFPOS += TEXTLEN&lt;br /&gt;
         END&lt;br /&gt;
         FOR FMC = 1 TO FMAX&lt;br /&gt;
            IF FMC # 1 THEN&lt;br /&gt;
               TEXTLEN = 1&lt;br /&gt;
               BUFFER[BUFPOS,TEXTLEN] = @VM&lt;br /&gt;
               BUFPOS += TEXTLEN&lt;br /&gt;
            END&lt;br /&gt;
            TEXT = ARRAY(FMC,VMC)&lt;br /&gt;
            TEXTLEN = LEN(TEXT)&lt;br /&gt;
            BUFFER[BUFPOS,TEXTLEN] = TEXT&lt;br /&gt;
            BUFPOS += TEXTLEN&lt;br /&gt;
         NEXT FMC&lt;br /&gt;
      NEXT VMC&lt;br /&gt;
***&lt;br /&gt;
* Done.&lt;br /&gt;
***&lt;br /&gt;
      ITEM = BUFFER&lt;br /&gt;
      RETURN&lt;br /&gt;
   END&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
http://www.autopower.com/rgozar/pixel.gif&lt;/div&gt;</summary>
		<author><name>Conversion script</name></author>
	</entry>
</feed>