HP Forums
Creating array inside program - 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: Creating array inside program (/thread-3262.html)



Creating array inside program - Marcio - 03-04-2015 10:01 PM

HI all,

Would you be kind enough as to explain why I can't create an array using a FOR loop like this?
Code:

EXPORT TEST()
BEGIN
LOCAL c, G;
FOR c FROM 1 to 3 DO
      G(c):=c^2+1;
END;
RETURN G(1)+G(3);
END;
Prime will complain there is an invalid input.

THanks


RE: Creating array inside program - Tim Wessman - 03-04-2015 10:15 PM

I see a local variable G (initialized to real number of 0 by default if nothing else is given) and not a vector/array...

LOCAL G:=[0];


RE: Creating array inside program - Marcio - 03-04-2015 10:29 PM

Smile
Thanks