Problems with return value of function
06-25-2017, 02:44 PM
Post: #1
 Powersoft Member Posts: 83 Joined: Feb 2015
Problems with return value of function
I am starting to program the HP Prime again after a long time!
Try to start with a simple program that is running almost perfect.
See program below.
In the export function a call the subroutine Eccentricity is placed, this should give back a value of E.
It's give the value "0" back. But when I print it before the Return it has a value.
I can't understand why this is happens. Please need some help!

Thanks for any help

Code:
Eccentricity(ecc,M) ; EXPORT KEPLER(ecc,M) BEGIN PRINT;  //Clear screen LOCAL E; //Local variable E=Eccentricity(ecc,M); PRINT("E="+E); HAngle:=0; END; Eccentricity(ecc,M)  // kepler's routine BEGIN LOCAL Rad2Deg,E,F,err,iter; print("ecc = "+ecc);  //ecentricity print("M = "+M); HAngle:=1; //Degree mode Rad2Deg := 180 / pi;  //start values for iteration E := M + (ecc * sin(M) * (1.0 + (ecc * cos(M)))); F := E - (E - (Rad2Deg * ecc * sin(E)) - M) / (1 - ecc * cos(E)); err := abs(F - E); iter:=0; print(err); WHILE (err > 1e-9) DO   iter := iter + 1;   F := E - (E - (Rad2Deg * ecc * sin(E)) - M) / (1 - ecc * cos(E));   err := abs (F - E);   //print(err);   E := F; END; print("iterations = "+iter); print("E = "+E); print("F = "+F); RETURN E; END;
 « Next Oldest | Next Newest »

 Messages In This Thread Problems with return value of function - Powersoft - 06-25-2017 02:44 PM RE: Problems with return value of function - Didier Lachieze - 06-25-2017, 03:11 PM

User(s) browsing this thread: 1 Guest(s)