HP Forums
Maximum number of LOCAL variables? - 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: Maximum number of LOCAL variables? (/thread-862.html)



Maximum number of LOCAL variables? - Ben Fairbank - 03-09-2014 06:48 AM

I am getting syntax errors in a program that has more LOCAL variables than I have used before, and the error cursor always goes to a variable in my LOCAL variable list. named maxheight I can find no flaw in the variable (but, who knows?). Several questions come to mind:
Is there a maximum number of permitted local variables? If so, what is it?
Can a LOCAL list be split and continued on a second or third line? If so, how?
What IS the maximum line length permitted in a Prime program?
Does the language permit the inclusion of more than one LOCAL statement?
These seem to be pretty basic questions, but I cannot find information about them in the "User Guide." Is there any more comprehensive source of information??

Many thanks for information on these.

Ben Fairbank


RE: Maximum number of LOCAL variables? - eried - 03-09-2014 06:59 AM

You can use any local statements you want.

Code:
local aa,ab;
local ac;
local ad:=1;
local ae:=aa,af:=ab;

Post your code, the error is probably in another line.


RE: Maximum number of LOCAL variables? - patrice - 03-09-2014 07:20 AM

maximum is 8 variables in a LOCAL line.
as many LOCAL lines as you need.


RE: Maximum number of LOCAL variables? - Ben Fairbank - 03-09-2014 08:15 AM

Eried --
Thank you for the suggestion.
Here are the lines I think are most likely to be giving the error:

LOCAL pp, qq, xcor, pi, denom, height, num, xmode, maxheight,propheight,
finalheight; [this is all on one line]

many lines omitted

// Plot the distribution:
FOR X FROM 15 TO 303 STEP 1 DO
xcor := (X-15)/288;
num := (xcor^(pp-1))*((1-xcor)^(qq-1));
propheight := num/(denom*maxheight);
finalheight := 160 - propheight*156;
PIXON(X,finalheight);
PIXON(X,(finalheight+1));
END;

The above lines simply step through X-axis lines from 0 to 1 and plot the distribution of the y variable associated with X.

If I comment these lines out, AND remove their variables from the LOCAL list, the syntax error stops appearing.
Ben


RE: Maximum number of LOCAL variables? - eried - 03-09-2014 11:47 AM

As patrice said, you have to split that local in 2 (8 vars max per local)