<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Stuck! I can't get a numeric value from my table.</title>
    <link>http://www.mapleprimes.com/questions/130526-Stuck-I-Cant-Get-A-Numeric-Value-From-My-Table</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 09 Jun 2026 07:41:05 GMT</lastBuildDate>
    <pubDate>Tue, 09 Jun 2026 07:41:05 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Stuck! I can't get a numeric value from my table.</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Stuck! I can't get a numeric value from my table.</title>
      <link>http://www.mapleprimes.com/questions/130526-Stuck-I-Cant-Get-A-Numeric-Value-From-My-Table</link>
    </image>
    <item>
      <title>local variable</title>
      <link>http://www.mapleprimes.com/questions/130526-Stuck-I-Cant-Get-A-Numeric-Value-From-My-Table?ref=Feed:MaplePrimes:Stuck! I can't get a numeric value from my table.:Comments#answer130537</link>
      <itunes:summary>&lt;p&gt;I didn't see the call to f in &lt;strong&gt;conscongs&lt;/strong&gt;, but no matter.&amp;nbsp; The error message that Maple is raising is informative:&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;final value in for loop must be numeric or character.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In f, the final value of the for loop is the variable &lt;strong&gt;numccs&lt;/strong&gt;. That variable is local to &lt;strong&gt;conscongs&lt;/strong&gt;, so its value will be unknown to &lt;strong&gt;f&lt;/strong&gt;. Actually, in the context of f, numccs is a global variable (because it wasn't declared), one that is different from the variable of the same name that is local to conscongs. You could declare numcss as a global variable inside of conscongs, however, that usually isn't the best way to go.&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;I didn't see the call to f in &lt;strong&gt;conscongs&lt;/strong&gt;, but no matter.&amp;nbsp; The error message that Maple is raising is informative:&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;final value in for loop must be numeric or character.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In f, the final value of the for loop is the variable &lt;strong&gt;numccs&lt;/strong&gt;. That variable is local to &lt;strong&gt;conscongs&lt;/strong&gt;, so its value will be unknown to &lt;strong&gt;f&lt;/strong&gt;. Actually, in the context of f, numccs is a global variable (because it wasn't declared), one that is different from the variable of the same name that is local to conscongs. You could declare numcss as a global variable inside of conscongs, however, that usually isn't the best way to go.&amp;nbsp;&lt;/p&gt;</description>
      <guid>130537</guid>
      <pubDate>Fri, 10 Feb 2012 06:37:22 Z</pubDate>
      <itunes:author>Joe Riel</itunes:author>
      <author>Joe Riel</author>
    </item>
    <item>
      <title>some methods</title>
      <link>http://www.mapleprimes.com/questions/130526-Stuck-I-Cant-Get-A-Numeric-Value-From-My-Table?ref=Feed:MaplePrimes:Stuck! I can't get a numeric value from my table.:Comments#answer130539</link>
      <itunes:summary>&lt;p&gt;As Joe mentions, your implementation is not allowing f to see the value of numccs which was assigned inside conscongs (where it is declared as a local).&lt;/p&gt;
&lt;p&gt;There are a number of different ways to deal with that. Here are four below, following a shortened version of the failed attempt. (I would prefer the first two workarounds over the last two.)&lt;/p&gt;
&lt;pre&gt;restart: # your failure
c:=proc() local numccs;
     numccs:=1;
     f();
   end proc:
f := proc() local i;
       for i from 1 to numccs do print(ok);
       end do;
     end proc:

c();
Error, (in f) final value in for loop must be numeric or character

restart: # passing value
f := proc(num) local i;
       for i from 1 to num do print(ok);
       end do;
     end proc:
c:=proc() local numccs;
     numccs:=1;
     f(numccs);
   end proc:

c();
                               ok

restart: # module local
m:=module() export c, f; local numccs;
   c:=proc() numccs:=1; f(); end proc:
   f := proc() local i;
          for i from 1 to eval(numccs) do print(ok);
          end do;
        end proc:
end module:

m:-c();
                               ok

restart: # lexical scoping
c:=proc() local numccs, f;
     f := proc() local i;
            for i from 1 to eval(numccs) do print(ok);
            end do;
         end proc:
     numccs:=1;
     f();
   end proc:

c();
                               ok

restart: # global
f := proc() global numccs; local i;
       for i from 1 to numccs do print(ok);
       end do;
     end proc:
c:=proc() global numccs;
     numccs:=1;
     f();
   end proc:

c();
                               ok
&lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;As Joe mentions, your implementation is not allowing f to see the value of numccs which was assigned inside conscongs (where it is declared as a local).&lt;/p&gt;
&lt;p&gt;There are a number of different ways to deal with that. Here are four below, following a shortened version of the failed attempt. (I would prefer the first two workarounds over the last two.)&lt;/p&gt;
&lt;pre&gt;restart: # your failure
c:=proc() local numccs;
     numccs:=1;
     f();
   end proc:
f := proc() local i;
       for i from 1 to numccs do print(ok);
       end do;
     end proc:

c();
Error, (in f) final value in for loop must be numeric or character

restart: # passing value
f := proc(num) local i;
       for i from 1 to num do print(ok);
       end do;
     end proc:
c:=proc() local numccs;
     numccs:=1;
     f(numccs);
   end proc:

c();
                               ok

restart: # module local
m:=module() export c, f; local numccs;
   c:=proc() numccs:=1; f(); end proc:
   f := proc() local i;
          for i from 1 to eval(numccs) do print(ok);
          end do;
        end proc:
end module:

m:-c();
                               ok

restart: # lexical scoping
c:=proc() local numccs, f;
     f := proc() local i;
            for i from 1 to eval(numccs) do print(ok);
            end do;
         end proc:
     numccs:=1;
     f();
   end proc:

c();
                               ok

restart: # global
f := proc() global numccs; local i;
       for i from 1 to numccs do print(ok);
       end do;
     end proc:
c:=proc() global numccs;
     numccs:=1;
     f();
   end proc:

c();
                               ok
&lt;/pre&gt;</description>
      <guid>130539</guid>
      <pubDate>Fri, 10 Feb 2012 08:54:48 Z</pubDate>
      <itunes:author>pagan</itunes:author>
      <author>pagan</author>
    </item>
  </channel>
</rss>