Bug? or my error?
03-13-2016, 04:07 AM
Post: #1
 ttw Member Posts: 261 Joined: Jun 2014
Bug? or my error?
I have been spending some time trying to get the follow program (and several similar programs) to work. They (may) work for a while then failW with the error "Error: invalid input" with the "info" button showing the lines with "nextprime" and "append" showing. Sometimes the programs work for a while.

I think I must have something global being changed, but I cannot find it.

EXPORT Erro1(NN)
BEGIN
LOCAL CC,II,LL;
cc:=2;LL:={2};
FOR II FROM 2 TO NN DO
CC:=nextprime(CC);
LL:=append(LL,CC);
END;
PRINT (LL);
END;

I have tried changing variable names to single letter (global) or making temporaries. When I insert PRINT statements before the offending lines, these just print the number 2.
03-13-2016, 09:39 AM
Post: #2
 Thomas_Sch Senior Member Posts: 390 Joined: Dec 2013
RE: Bug? or my error?
(03-13-2016 04:07 AM)ttw Wrote:  I have been spending some time trying to get the follow program (and several similar programs) to work. They (may) work for a while then failW with the error "Error: invalid input" with the "info" button showing the lines with "nextprime" and "append" showing. Sometimes the programs work for a while.

I think I must have something global being changed, but I cannot find it.
Code:
 EXPORT Erro1(NN) BEGIN   LOCAL CC,II,LL;   cc:=2;LL:={2};   //  cc  vs. CC   FOR II FROM 2 TO NN DO     CC:=nextprime(CC);  //     LL:=append(LL,CC);   END;   PRINT (LL); END;
I have tried changing variable names to single letter (global) or making temporaries. When I insert PRINT statements before the offending lines, these just print the number 2.

In my opinion you are using two different varalbles cc and CC.
Trying to run your program in the virtual prime throws an syntac arror at
Code:
 cc:=2; ..
Try to use only one of them.
03-13-2016, 09:51 AM
Post: #3
 Didier Lachieze Senior Member Posts: 1,525 Joined: Dec 2013
RE: Bug? or my error?
Replacing cc by CC, I'm not able to reproduce your error message, both on my real Prime and the Android application.

Note that you can replace the FOR loop by MAKELIST :
Code:
EXPORT Erro1(NN) BEGIN   LOCAL CC,LL;   LL:=MAKELIST(CC:=nextprime(CC),K,1,NN);   PRINT (LL); END;
03-13-2016, 11:16 AM
Post: #4
 ttw Member Posts: 261 Joined: Jun 2014
RE: Bug? or my error?
I typed wrong. They are both the same CC. It's an intermittent error which makes it hard for me to track.

As every variable (except the argument to the routine) is LOCAL and each variable is initialized each time, I'm having trouble figuring things out. I'm not impressed with the PRIME; it's fast but so far useless. (And when I tried to update through the USB, my computer got fried so I cannot trust plugging it into another computer, too expensive.)

I also have trouble with other similar programs which create lists using "append" or "concat" and I get errors calling "nextprime" or "isPrime?" (I think that's the spelling.) All these error are intermittent. I may try just doing a hard reset even at the cost of having to re-type in all my programs.
03-13-2016, 11:45 AM
Post: #5
 Thomas_Sch Senior Member Posts: 390 Joined: Dec 2013
RE: Bug? or my error?
(03-13-2016 11:16 AM)ttw Wrote:  ...
I may try just doing a hard reset even at the cost of having to re-type in all my programs.
You could save/backup all your programs via the Connectivity Kit.
03-13-2016, 11:56 AM
Post: #6
 DrD Senior Member Posts: 1,133 Joined: Feb 2014
RE: Bug? or my error?

I presume you have the latest firmware installed, if not,that's a good place to start. There may be a problem with the nextprime command, as detailed in the reference above.

Other than that, I have had a few hpprime calcs for quite awhile, and like them very much, warts and all. The product development team is very responsive, here and elsewhere, to help work out issues. USB has not been a problem in all of my work with the prime, (so far, and I use them everyday). After retiring my hp50g, (batteries removed), shortly after I bought my first prime, I haven't needed it since. (I'm just trying to help put a positive spin on your feeling of not being impressed with the prime, so far).

Don't forget to make a backup from your calc, if your decide to format it. You'll be able to get all your programs back, afterwards.

-Dale-
03-13-2016, 11:57 AM
Post: #7
 Arno K Senior Member Posts: 463 Joined: Mar 2015
RE: Bug? or my error?
I have only replaced your variable names to lower case and the program works correct, that is provides a list of nn primes. Here I think the error may occur as Home thinks C to be a global variable and CC then is interpreted as C*C.
Arno
03-13-2016, 03:15 PM
Post: #8
 ttw Member Posts: 261 Joined: Jun 2014
RE: Bug? or my error?
Seems like it's like the error referred to in the link give up thread. I re-wrote everything avoiding any functions (except "append" and "SUB") and so far things work. (One never knows with an intermittent error.)
 « Next Oldest | Next Newest »

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