is my program too big to edit?
07-29-2015, 09:56 AM (This post was last modified: 07-29-2015 09:59 AM by salvomic.)
Post: #1
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
is my program too big to edit?
hi,
the almost complete version of my Astronomy program (here) is now 250 kB into the Prime...

I noted often a problem checking for errors with shift-Program: if there is an error (syntax) or the Calc hangs or it resets...
Not always, but enough often.

I wonder if my program is too big or if there are some other issues...

I think to complete the last function, but I' like to could expand it without problems, if it's needed.

Another thing, indeed, is that editing more time the program (last firmware) the memory lacks and after many times (I cannot say how many) sometimes the Prime return a "Insufficient memory" message and doesn't save more; only a reset is ok to restart.

Thank you for help

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
07-29-2015, 10:43 AM
Post: #2
 DrD Senior Member Posts: 1,133 Joined: Feb 2014
RE: is my program too big to edit?
In general you can:

1. Modularize your program, by using 'external' subprograms that do not occupy memory until needed, and release memory when done. Each subprogram is much shorter, thus saving program memory.

2. Use reserved variables instead of locals.

3. Reduce the number of User variables or CAS vars, by re-using vars that are no longer necessary.

Would any of these things be helpful for you?

-Dale-
07-29-2015, 10:53 AM (This post was last modified: 07-29-2015 10:53 AM by salvomic.)
Post: #3
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
RE: is my program too big to edit?
(07-29-2015 10:43 AM)DrD Wrote:  In general you can:

1. Modularize your program, by using 'external' subprograms that do not occupy memory until needed, and release memory when done. Each subprogram is much shorter, thus saving program memory.

2. Use reserved variables instead of locals.

3. Reduce the number of User variables or CAS vars, by re-using vars that are no longer necessary.

Would any of these things be helpful for you?

-Dale-

perhaps every of them, Dale...
but this program is become complex: 90% of functions call other function...
One (big) check also if the app of Marcel, Astro Lab 4, is installed, and decides if to use it or continue with the inside method...

I think to modularize, but I've not a precise idea about how i't better.
The vars are indeed too many but at the beginning I thought to have all in one inside; when the program grew I lost the control of it :-(
The modules, then, should be installed all by the user. I (for now) cannot make an app, as I think to help that of Marcel, already a good app, with my "ancillary" functions...
So, I cannot use AVars, and some (big!) list are included inside the program, and they make grow the dimension of it.

I appreciate every advice or hint about modularization, I'm searching to make myself an idea, a clear idea.

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
07-29-2015, 03:49 PM (This post was last modified: 07-29-2015 03:55 PM by Tim Wessman.)
Post: #4
 Tim Wessman Senior Member Posts: 2,283 Joined: Dec 2013
RE: is my program too big to edit?
Well, two things to keep in mind.

Anything in AVars will be kept in RAM. Thus a 1MB list will always be consuming 1MB. If it is something you think will be large, it really should be kept in a file and only pulled in on use, then discarded when not needed.

256kb should not be problematic for the editor I would anticipate. I'll look at it and see if I can see what you are reporting.

TW

Although I work for HP, the views and opinions I post here are my own.
07-29-2015, 03:57 PM (This post was last modified: 07-29-2015 03:59 PM by salvomic.)
Post: #5
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
RE: is my program too big to edit?
(07-29-2015 03:49 PM)Tim Wessman Wrote:  Well, two things to keep in mind.

Anything in AVars will be kept in RAM. Thus a 1MB list will always be consuming 1MB. If it is something you think will be large, it really should be kept in a file and only pulled in on use.

256kb should not be problematic for the editor I would anticipate. I'll look at it and see if I can see what you are reporting.

thank you, Tim.
This morning I wrote for error in one of the last lines (about 3300) 0,4 instead of 0.4 and the editor crashed after I choose Check, then I repeated the check and the Prime reset. I found manually the error, corrected it and all was ok.
another time I wrote a variable "nameplanet" as "namplanet" and it hanged again.
I noted also that sometimes (not always) the Editor doesn't hang if the calc was not connected to CK. When it hanged no luck to use on-Symb: pin hole reset was necessary.

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
07-30-2015, 05:10 AM
Post: #6
 cyrille de brébisson Senior Member Posts: 1,047 Joined: Dec 2013
RE: is my program too big to edit?
Hello,

Do you get the same crashes on the emulator and the calculator or only on the calc?
If the later, then it might be a memory issue...
Could you share a crashing piece of text so that I can use it to debug the code?

Cyrille
07-30-2015, 05:48 AM
Post: #7
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
RE: is my program too big to edit?
(07-30-2015 05:10 AM)cyrille de brébisson Wrote:  Hello,

Do you get the same crashes on the emulator and the calculator or only on the calc?
If the later, then it might be a memory issue...
Could you share a crashing piece of text so that I can use it to debug the code?

Cyrille

hi Cyrille,
thank you for help.
I haven't tried on emulator.
Here below the last function. Now it works, but for example, when I wrote "0,0034*sin(2*Mprime)" instead of "0.0034*sin(2*Mprime)" the Prime editor crashed or hanged, after hitting the soft key for checking errors.
Also writing a non existent variable hanged.
When the file was about 210-220 kB I could use editor without issues. So I though about file dimension, but who know it?

In the code you can comment this two function (they are working in the rest of program)

Code:
   nowdate:= makeDateList(datelist);   yy:= nowdate(1);   doy:= dayOfYear(datelist);

Salvo

Code:
 EXPORT moonNodes(datelist) BEGIN   LOCAL nowdate, yy, doy, k, T, jde, jde1;   LOCAL D, M, Mprime, omega, V, P;   LOCAL asc, desc, ee;   nowdate:= makeDateList(datelist);   yy:= nowdate(1);   doy:= dayOfYear(datelist);   yy:= yy+doy/365.25; // "fractional year"   k:= (yy-2000.05)*13.4223;  // perigee   k:= IP(k); // ascending node   T:= k/1342.23;   ee:= 1-0.002516*T-0.0000074*T^2;  // multiply those w/ M *ee   D:= 183.6380+331.73735682*k+0.0014852*(T^2)+0.00000209*(T^3)-0.000000010*(T^4); // elongation   D:= simp_angle(D);   M:= 17.4006+26.82037250*k+0.0001186*(T^2)+0.00000006*(T^3); // Sun anomaly   M:= simp_angle(M);   Mprime:= 38.3776+355.52747313*k+0.0123499*(T^2)+0.000014627*(T^3)-0.000000069*(T^4); // Moon anomaly   Mprime:= simp_angle(Mprime);   omega:= 123.9767-1.44098956*k+0.0020608*(T^2)+0.00000214*(T^3)-0.000000016*(T^4); // node   omega:= simp_angle(omega);   V:= 299.75+132.85*T-0.009173*(T^2);   P:= omega+272.75-2.3*T;   jde:= 2451565.1619+27.21222087*k+0.0002762*(T^2)+0.000000021*(T^3)-0.000000000088*(T^4)-0.4721*sin(Mprime);   jde:= jde - 0.1649*sin(2*D)-0.0868*sin(2*D-Mprime)+0.0084*sin(2*D+Mprime)-0.0083*sin(2*D-M)*ee;   jde:= jde - 0.0039*sin(2*D-M-Mprime)*ee+0.0034*sin(2*Mprime)-0.0031*sin(2*D-2*Mprime)+0.0030*sin(2*D+M)*ee;   jde:= jde + 0.0028*sin(M-Mprime)*ee+0.0026*sin(M)*ee+0.0025*sin(4*D)+0.0024*sin(D)+0.0022*sin(M+Mprime)*e​e;   jde:= jde + 0.0017*sin(omega)+0.0014*sin(4*D-Mprime)+0.0005*sin(2*D-M-Mprime)*ee+0.0004*sin(2*D-M+Mprime)*ee;   jde:= jde - 0.0003*sin(2*D-2*M)+0.0003*sin(4*D-M)+0.0003*sin(V)+0.0003*sin(P);   asc:= makeDateList(dateFromJD(jde));   k:= k+0.5; // descending node   T:= k/1342.23;   ee:= 1-0.002516*T-0.0000074*T^2;  // multiply those w/ M *ee   D:= 183.6380+331.73735682*k+0.0014852*(T^2)+0.00000209*(T^3)-0.000000010*(T^4); // elongation   D:= simp_angle(D);   M:= 17.4006+26.82037250*k+0.0001186*(T^2)+0.00000006*(T^3); // Sun anomaly   M:= simp_angle(M);   Mprime:= 38.3776+355.52747313*k+0.0123499*(T^2)+0.000014627*(T^3)-0.000000069*(T^4); // Moon anomaly   Mprime:= simp_angle(Mprime);   omega:= 123.9767-1.44098956*k+0.0020608*(T^2)+0.00000214*(T^3)-0.000000016*(T^4); // node   omega:= simp_angle(omega);   V:= 299.75+132.85*T-0.009173*(T^2);   P:= omega+272.75-2.3*T;   jde1:= 2451565.1619+27.21222087*k+0.0002762*(T^2)+0.000000021*(T^3)-0.000000000088*(T^4)-0.4721*sin(Mprime);   jde1:= jde1 - 0.1649*sin(2*D)-0.0868*sin(2*D-Mprime)+0.0084*sin(2*D+Mprime)-0.0083*sin(2*D-M)*ee;   jde1:= jde1 - 0.0039*sin(2*D-M-Mprime)*ee+0.0034*sin(2*Mprime)-0.0031*sin(2*D-2*Mprime)+0.0030*sin(2*D+M)*ee;   jde1:= jde1 + 0.0028*sin(M-Mprime)*ee+0.0026*sin(M)*ee+0.0025*sin(4*D)+0.0024*sin(D)+0.0022*sin(M+Mprime)*e​e;   jde1:= jde1 + 0.0017*sin(omega)+0.0014*sin(4*D-Mprime)+0.0005*sin(2*D-M-Mprime)*ee+0.0004*sin(2*D-M+Mprime)*ee;   jde1:= jde1 - 0.0003*sin(2*D-2*M)+0.0003*sin(4*D-M)+0.0003*sin(V)+0.0003*sin(P);   desc:= makeDateList(dateFromJD(jde1));    RETURN({asc, desc}); END;

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
09-08-2015, 04:43 PM (This post was last modified: 09-08-2015 06:02 PM by salvomic.)
Post: #8
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
RE: is my program too big to edit?
Tim, Cyrille,
I tired also in emulator and I get the same issues: program crashes when I modify or add something...
I don't know why, I hope it doesn't be to big indeed.

TIA!

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
09-08-2015, 06:34 PM
Post: #9
 eried Senior Member Posts: 744 Joined: Dec 2013
RE: is my program too big to edit?
(09-08-2015 04:43 PM)salvomic Wrote:  Tim, Cyrille,
I tired also in emulator and I get the same issues: program crashes when I modify or add something...
I don't know why, I hope it don't be to big indeed.

TIA!

Salvo

I was able to run your program with some tweaks but it is clearly unstable, after two edits the emulator crashed and all programs were wiped. Not sure what is the issue, but I noticed that you could improve several sections, like for example the planets section:

Maybe you can track down the issue after cleaning the code from all these stuff bulking it.

My website: erwin.ried.cl
09-08-2015, 07:56 PM (This post was last modified: 09-08-2015 08:27 PM by salvomic.)
Post: #10
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
RE: is my program too big to edit?
(09-08-2015 06:34 PM)eried Wrote:  I was able to run your program with some tweaks but it is clearly unstable, after two edits the emulator crashed and all programs were wiped. Not sure what is the issue, but I noticed that you could improve several sections, like for example the planets section:
...
Maybe you can track down the issue after cleaning the code from all these stuff bulking it.

hi Eried,
you're right, I should cleaning the code a lot...
I'll try soon, anyway.
Generally I don't love much to use globals, but in this case maybe it's the best approach...
I hope somebody could help me, thanks!

thank you
Salvo

EDIT:
however for no is a bit difficult to amend it, if every time I change something in CK and send it to the calculator, my Prime crashes...
I don't remember at what level it was still good, but after one of the last functions I added it began the problem with the crashes...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
09-09-2015, 10:39 AM
Post: #11
 eried Senior Member Posts: 744 Joined: Dec 2013
RE: is my program too big to edit?
(09-08-2015 07:56 PM)salvomic Wrote:
(09-08-2015 06:34 PM)eried Wrote:  I was able to run your program with some tweaks but it is clearly unstable, after two edits the emulator crashed and all programs were wiped. Not sure what is the issue, but I noticed that you could improve several sections, like for example the planets section:
...
Maybe you can track down the issue after cleaning the code from all these stuff bulking it.

hi Eried,
you're right, I should cleaning the code a lot...
I'll try soon, anyway.
Generally I don't love much to use globals, but in this case maybe it's the best approach...
I hope somebody could help me, thanks!

thank you
Salvo

EDIT:
however for no is a bit difficult to amend it, if every time I change something in CK and send it to the calculator, my Prime crashes...
I don't remember at what level it was still good, but after one of the last functions I added it began the problem with the crashes...

Yeah I understand but since your program is quite big already is not that easy to get help. My recommendation is to do some rudimentary versioning with added documentary.

First start with an empty program and add one by one optimized functions of the original code writing what they receive and output (easy to get help like that later). After each test save that as a version and write what happened with that version in the prime.

The main issue you will encounter is that you cant trust the environment (the prime)... and that is usually the last thing you may think is bugged when developing something.

My website: erwin.ried.cl
09-09-2015, 10:53 AM
Post: #12
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
RE: is my program too big to edit?
yes, Eried, thanks again for your important advice, I hope to have time to do that soon.
For now, however, I don't understand why the problems there are first to run the program, already with the "Edit Program" procedure: if there is an error (syntax) the Calc hangs or it resets, only if the Program Edit compile it...
I would so understand *when* (at which level) I introduced any error or bug, as it first worked well (or, almost well)...

For this reason I thought to the dimension as a probably cause of it...

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
09-10-2015, 05:31 AM
Post: #13
 cyrille de brébisson Senior Member Posts: 1,047 Joined: Dec 2013
RE: is my program too big to edit?
Hello,

If you could send me (or post here) the files that are causing the crash (or the file that is not causing it as well as the modifications that cause it), I could use it to find the reason for the crash. That would be very appreciated.

Cyrille
09-10-2015, 07:18 AM
Post: #14
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
RE: is my program too big to edit?
(09-10-2015 05:31 AM)cyrille de brébisson Wrote:  Hello,

If you could send me (or post here) the files that are causing the crash (or the file that is not causing it as well as the modifications that cause it), I could use it to find the reason for the crash. That would be very appreciated.

Cyrille

very kind of you, Cyrille!
I've just sent a PM to you with the file link.
If others of us want help also, the file that should work (but by me gives issues editing it) is here in the HP Prime Software Library section of the Forum (the program runs better if the Astro Lab 4 app by Marcel is installed, you can find it also in the Library).

thanks!

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
 « Next Oldest | Next Newest »

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