<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ksh two dimensional array ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878509#M703907</link>
    <description>Haven't time to get to heavily involved but I'm wondering if a single-dimension array would work, if you apply an offset in your programming; we used to do this in the old Radio Shack TRS-80 days as it's BASIC also had no support for multi-dimensional arrays.&lt;BR /&gt;&lt;BR /&gt;Example, with an array a[6,6] and the two indices being i,j ....&lt;BR /&gt;&lt;BR /&gt;The single array  a[x]  would yield:&lt;BR /&gt;&lt;BR /&gt;x = (i-1) * 6 + j&lt;BR /&gt;&lt;BR /&gt;The only caviat is that the upper limit of one of the indices must be known or arbitrarily set, in this case 6.&lt;BR /&gt;</description>
    <pubDate>Fri, 07 Jan 2005 09:00:30 GMT</pubDate>
    <dc:creator>Fred Martin_1</dc:creator>
    <dc:date>2005-01-07T09:00:30Z</dc:date>
    <item>
      <title>ksh two dimensional array ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878506#M703904</link>
      <description>Can someone help me with this.  Example prefered. in ksh.&lt;BR /&gt;&lt;BR /&gt;I want to build a two-dimensional array with columns and rows like a spreadsheet and have the rightmost column be a total of each row, and the bottom row be a total of the entire column above it:&lt;BR /&gt;&lt;BR /&gt;.......OS:  AIX  HP-UX  Linux  Total&lt;BR /&gt;Grp:   A     5      10     2     17&lt;BR /&gt;       B     0       3     9     12&lt;BR /&gt;      --    --      --    --     --&lt;BR /&gt;     Tot     5      13    11     29&lt;BR /&gt;&lt;BR /&gt;I have never worked with two-dimensional arrays in ksh.  Can you do that?&lt;BR /&gt;&lt;BR /&gt;typeset A [10,10]&lt;BR /&gt;A[2,3]=9</description>
      <pubDate>Thu, 06 Jan 2005 09:32:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878506#M703904</guid>
      <dc:creator>Stuart Abramson</dc:creator>
      <dc:date>2005-01-06T09:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: ksh two dimensional array ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878507#M703905</link>
      <description>two-dimensional arrays are not supported. You can simulate a two-dimensional with a one dimensional.&lt;BR /&gt; &lt;BR /&gt;In your example-&lt;BR /&gt;ncols=10      ; # specifiy number of columns&lt;BR /&gt;p1=2 ; p2=3   ; # Desired position&lt;BR /&gt;# Convert position p1,p2 to offset in "A"&lt;BR /&gt;let "ix=ncols*(p1-1)+p2"&lt;BR /&gt;A[$ix]=9&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;(PS - another tool like "perl" might be a better way to go...)&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Jan 2005 10:09:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878507#M703905</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-01-06T10:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: ksh two dimensional array ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878508#M703906</link>
      <description>That dog won't hunt. Arrays in the shell must be single dimensional.&lt;BR /&gt;Neiter A[2,3] or A[2][3] is valid shell syntax.&lt;BR /&gt;&lt;BR /&gt;Probably the most straightforward approach would be awk --- but it only supports single-dimensional arrays as well BUT awks arrays will work. How can that be? Awk's array indices are associative rather that purely numeric like those of the shell.&lt;BR /&gt;&lt;BR /&gt;This means that X[tom],X[harry], ... are perfectly valid so X[2,3] works as well because "2,3" is treated as a string.</description>
      <pubDate>Thu, 06 Jan 2005 10:13:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878508#M703906</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-01-06T10:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: ksh two dimensional array ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878509#M703907</link>
      <description>Haven't time to get to heavily involved but I'm wondering if a single-dimension array would work, if you apply an offset in your programming; we used to do this in the old Radio Shack TRS-80 days as it's BASIC also had no support for multi-dimensional arrays.&lt;BR /&gt;&lt;BR /&gt;Example, with an array a[6,6] and the two indices being i,j ....&lt;BR /&gt;&lt;BR /&gt;The single array  a[x]  would yield:&lt;BR /&gt;&lt;BR /&gt;x = (i-1) * 6 + j&lt;BR /&gt;&lt;BR /&gt;The only caviat is that the upper limit of one of the indices must be known or arbitrarily set, in this case 6.&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Jan 2005 09:00:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878509#M703907</guid>
      <dc:creator>Fred Martin_1</dc:creator>
      <dc:date>2005-01-07T09:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: ksh two dimensional array ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878510#M703908</link>
      <description>Thanks, all.  I'll just bumble along with one array per row...</description>
      <pubDate>Mon, 10 Jan 2005 09:40:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-two-dimensional-array/m-p/4878510#M703908</guid>
      <dc:creator>Stuart Abramson</dc:creator>
      <dc:date>2005-01-10T09:40:17Z</dc:date>
    </item>
  </channel>
</rss>

