HP Forums
Array - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Array (/thread-3593.html)



Array - Powersoft - 04-09-2015 08:27 AM

Hello,

I have crate this simple array read program:

EXPORT test()
BEGIN
Local T45BL = [5128122, 280602, 277693, 173237, 55413,
46271, 32573, 17198, 9266, 8822,
8216, 4324, 4200, -3359, 2463,
2211, 2065, -1870, 1828, -1794,
-1749, -1565, -1491, -1475, -1410,
-1344, -1335, 1107, 1021, 833,
777, 671, 607, 596, 491,
-451, 439, 422, 421, -366,
-351, 331, 315, 302, -283,
-229, 223, 223, -220, -220,
-185, 181, -177, 176, 166,
-164, 132, -119, 115, 107];

for i from 0 to 59 do
print(T45BL[i]);
end;

It it compiling well, but when executed I get the error message
"Bad argument type"

Can someone help me with this?

Thanks for any help.

Jan Kromhout
Hellevoetsluis-NL


RE: Array - Tyann - 04-09-2015 10:45 AM

(04-09-2015 08:27 AM)Powersoft Wrote:  Hello,

I have crate this simple array read program:

EXPORT test()
BEGIN
Local T45BL = [5128122, 280602, 277693, 173237, 55413,
46271, 32573, 17198, 9266, 8822,
8216, 4324, 4200, -3359, 2463,
2211, 2065, -1870, 1828, -1794,
-1749, -1565, -1491, -1475, -1410,
-1344, -1335, 1107, 1021, 833,
777, 671, 607, 596, 491,
-451, 439, 422, 421, -366,
-351, 331, 315, 302, -283,
-229, 223, 223, -220, -220,
-185, 181, -177, 176, 166,
-164, 132, -119, 115, 107];

for i from 0 to 59 do
print(T45BL[i]);
end;

It it compiling well, but when executed I get the error message
"Bad argument type"

Can someone help me with this?

Thanks for any help.

Jan Kromhout
Hellevoetsluis-NL

Hello
local T45BL:=[...]
local i
FOR i FROM 1 TO 60 DO


RE: Array - DrD - 04-09-2015 10:59 AM

There were a few errors in the code you've shown but this should work:

Code:

EXPORT Test()
BEGIN
  Local i;
  Local T45BL:= [5128122, 280602, 277693, 173237, 55413,
                46271, 32573, 17198, 9266, 8822,
                8216, 4324, 4200, -3359, 2463,
                2211, 2065, -1870, 1828, -1794,
                -1749, -1565, -1491, -1475, -1410,
                -1344, -1335, 1107, 1021, 833,
                777, 671, 607, 596, 491,
                -451, 439, 422, 421, -366,
                -351, 331, 315, 302, -283,
                -229, 223, 223, -220, -220,
                -185, 181, -177, 176, 166,
                -164, 132, -119, 115, 107];

  for i from 1 to 60 do
    print(T45BL(i));
  end; // ends for 

END;



RE: Array - DrD - 04-09-2015 11:06 AM

Would you be able to make use of the length() command in your loop?

Code:

EXPORT Test()
BEGIN
  Local i;
  Local T45BL:= [5128122, 280602, 277693, 173237, 55413,
                46271, 32573, 17198, 9266, 8822,
                8216, 4324, 4200, -3359, 2463,
                2211, 2065, -1870, 1828, -1794,
                -1749, -1565, -1491, -1475, -1410,
                -1344, -1335, 1107, 1021, 833,
                777, 671, 607, 596, 491,
                -451, 439, 422, 421, -366,
                -351, 331, 315, 302, -283,
                -229, 223, 223, -220, -220,
                -185, 181, -177, 176, 166,
                -164, 132, -119, 115, 107];

  for i from 1 to length(T45BL) do
    print(T45BL(i));
  end; // ends for 

END;



RE: Array - Powersoft - 04-09-2015 02:27 PM

Thanks, this is great!


Would you be able to make use of the length() command in your loop?

Code:

EXPORT Test()
BEGIN
  Local i;
  Local T45BL:= [5128122, 280602, 277693, 173237, 55413,
                46271, 32573, 17198, 9266, 8822,
                8216, 4324, 4200, -3359, 2463,
                2211, 2065, -1870, 1828, -1794,
                -1749, -1565, -1491, -1475, -1410,
                -1344, -1335, 1107, 1021, 833,
                777, 671, 607, 596, 491,
                -451, 439, 422, 421, -366,
                -351, 331, 315, 302, -283,
                -229, 223, 223, -220, -220,
                -185, 181, -177, 176, 166,
                -164, 132, -119, 115, 107];

  for i from 1 to length(T45BL) do
    print(T45BL(i));
  end; // ends for 

END;
[/quote]