Post Reply 
HP_ELEMENTS and scroll building block
01-04-2014, 09:14 PM (This post was last modified: 04-10-2014 03:54 PM by Miguel Toro.)
Post: #1
HP_ELEMENTS and scroll building block
Hi,

Studying the code of Mic's Periodic table for the HP Prime, I detected some bugs :

1. When pressing ENTER, without actually clicking on an element before, may cause an error if the index B (global variable) is 0,
2. Synthetic elements not showing the information page,
3. Potential problems with some unintended recursion calls

So, since I finally received my HP Prime, I decided to learn about the language by making a revision of the code. I wanted to begin creating a basic building block for touch scrolling. Here is the code that of course could be much improved, but at least may be use to any kind of scrolling making the appropriate changes. Here is the code, then, for horizontal scroll using the mouse (touch scroll), hoping that you will find it useful:

Code:

// GLOBAL VARIABLES
HSIZE=640; // Total image horizontal size
width;
height;
marginx:=5;
marginy:=5;

BUILDIMAGE();

EXPORT HSCROLL()
BEGIN

  BUILDIMAGE();

  // LOCAL VARIABLES TO MANAGE THE SCROLLING
  LOCAL WNDBEG:=0, WNDEND=320, OFFSET, TOUCH, SMOOTH=64;
  LOCAL SELECTED:=0;
  BLIT_P(G0,G1,WNDBEG,0,WNDEND,240);
  WHILE 1 DO
    // MOUSE ACTION - SCROLL THE IMAGE, CLICK ACTIONS, etc.
    TOUCH:=MOUSE();
    IF SIZE(TOUCH(1)) THEN
      CASE
//        IF TOUCH(1,5)==0 THEN // Mouse click
//          MSGBOX("X= "+TOUCH(1,1)+" Y= "+TOUCH(1,2));
//        END;
        IF TOUCH(1,5)==2 THEN // Mouse drag
          OFFSET:=IP((TOUCH(1,3)-TOUCH(1,1))/SMOOTH);
          IF (WNDEND+OFFSET)>HSIZE THEN
             WNDBEG:=HSIZE-320;
             WNDEND:=HSIZE;
          ELSE
             IF (WNDBEG+OFFSET)<0 THEN
                WNDBEG:=0;
                WNDEND:=320;
             ELSE
                WNDBEG:=WNDBEG+OFFSET;
                WNDEND:=WNDEND+OFFSET;
             END;
          END;
        END;
      END;
    END;

    // KEYBOARD ACTIONS
    IF ISKEYDOWN(30) THEN // Commands if ENTER
      BREAK;
    END;
    IF ISKEYDOWN(4) THEN BREAK; END; // Stop the program is ESC

    BLIT_P(G0,G1,WNDBEG,0,WNDEND,240);
  END; 
END;

BUILDIMAGE()
BEGIN

  width:=HSIZE-5;
  height:=235;
  DIMGROB_P(G1,HSIZE,240); RECT(G1);
  RECT_P(G1,marginx,marginy,width,height,#000000,#FF0000); 
  TEXTOUT_P("This is a very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, long text",G1,10,110,2,RGB(65,65,65));

END;

And of course, you will find attached the new code for Mic's Periodic table. I like the new language. It is really powerful and fun to work with. I hope Mic will forgive me taking the liberty of making these changes.

*** UPDATE 2014-04-10 ****

Thanks to Orcinus for a change allowing the text not to be affected by color theme.


Regards,

Miguel


Attached File(s)
.zip  HP_ELEMENTS.zip (Size: 12.06 KB / Downloads: 30)
Find all posts by this user
Quote this message in a reply
01-05-2014, 02:23 AM
Post: #2
RE: HP_ELEMENTS and scroll building block
Did anyone get this to actually run?

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
01-05-2014, 02:43 AM
Post: #3
RE: HP_ELEMENTS and scroll building block
(01-05-2014 02:23 AM)Han Wrote:  Did anyone get this to actually run?

Hi Han,

Did you tried the version I attached to my post? It works, but if there is anything not working, could you please tell me what it is?

Thanks,

Miguel
Find all posts by this user
Quote this message in a reply
01-05-2014, 02:51 AM (This post was last modified: 01-05-2014 03:07 AM by Han.)
Post: #4
RE: HP_ELEMENTS and scroll building block
(01-05-2014 02:43 AM)Miguel Toro Wrote:  
(01-05-2014 02:23 AM)Han Wrote:  Did anyone get this to actually run?

Hi Han,

Did you tried the version I attached to my post? It works, but if there is anything not working, could you please tell me what it is?

Thanks,

Miguel

It appears to be a firmware bug, and not a bug in your program. If anyone else happens to not be able to run the program, make sure that you are not currently in the Spreadsheet app when you exit the program source for the periodic table.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
01-05-2014, 09:31 AM (This post was last modified: 01-05-2014 09:33 AM by Mic.)
Post: #5
RE: HP_ELEMENTS and scroll building block
No problem Miguel, you're welcome. I will try your changes.

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
02-22-2014, 04:28 PM
Post: #6
RE: HP_ELEMENTS and scroll building block
I am a NEWB having just received my new Prime a day ago,and I thought that it would be nice to try and download a program and see how to use the Connectivity Kit. I was successful in getting this program over to my new Prime, however, when I run it, all I get is a red screen with the words "This is a very looooooooooooong text"

Am I missing a step here to get the periodic table running on my HP Prime?

Also, what program should I use to open the zipped files - I am assuming some sort of text program? I ended up just copying and pasting the program from your post to get this far.


Thanks,
Nick
Find all posts by this user
Quote this message in a reply
02-23-2014, 06:27 AM (This post was last modified: 02-23-2014 06:27 AM by Mic.)
Post: #7
RE: HP_ELEMENTS and scroll building block
You can download the original program here :
http://mic.nic.free.fr/hp/Touch%20elemen...0Prime.zip

Just send the .hpprgm to your calc.

Tell me if you still have a problem.

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
02-23-2014, 10:22 PM
Post: #8
RE: HP_ELEMENTS and scroll building block
(02-22-2014 04:28 PM)NMihiylov Wrote:  I am a NEWB having just received my new Prime a day ago,and I thought that it would be nice to try and download a program and see how to use the Connectivity Kit. I was successful in getting this program over to my new Prime, however, when I run it, all I get is a red screen with the words "This is a very looooooooooooong text"

Am I missing a step here to get the periodic table running on my HP Prime?

Also, what program should I use to open the zipped files - I am assuming some sort of text program? I ended up just copying and pasting the program from your post to get this far.


Thanks,
Nick

Hi Nick,

The code in my post is just an example of how to implement scrolling. The ZIP file contains the actual HP_Elements program. You have to unzip it. If you use Windows, just right-click on the file and then choose extract all. The program is inside.

Hope that helps,

Miguel
Find all posts by this user
Quote this message in a reply
02-26-2014, 02:23 AM
Post: #9
RE: HP_ELEMENTS and scroll building block
I got that far, the extraction was no issue, however, where I am struggling now is how to get the program over to the calculator. As I may have mentioned I am a newb, do I cut and paste it in the () v or do I paste it after the word export or Begin?, I have tried several of these areas all with no luck, is there a way to "send" your program over to the calculator?

Thanks,

Nick
Find all posts by this user
Quote this message in a reply
02-26-2014, 03:31 AM
Post: #10
RE: HP_ELEMENTS and scroll building block
After you extract the *.hpprg file, copy it to this windows folder:

C:\Users\[your name]\AppData\Roaming\HP_Prime

Then, when you start the Virtual Prime, you will find the new program in the Program Catalog.

Connect the actual device to the PC via USB, then on the Virtual Prime "Calculator" menu (the windows progam menu, not on the calculator itself) select "Connect to" and pick your Prime (2nd once down).

Then on the Virtual Prime, navigate to select the new program in the Program Catalog, then tap the Send function key; this will download the program to your actual device.

Good luck.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
02-26-2014, 06:11 AM
Post: #11
RE: HP_ELEMENTS and scroll building block
Hello Nick,

You can try this to send the program :
http://mic.nic.free.fr/images/send_hpprime.png

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
02-26-2014, 09:20 AM
Post: #12
RE: HP_ELEMENTS and scroll building block
It works for me. Thanks! I like the fact that it no longer crashes when I scroll too far left or right. I would like to be able to use the cursor keys to move around the table rather than having to poke the screen to select the element I want, though.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
02-26-2014, 11:18 AM
Post: #13
RE: HP_ELEMENTS and scroll building block
Is it reasonable to request a post of HP_ELEMENTS.hpprgm in text format?

I have tried everything I have read and cannot load programs into the CK. I CK version: 2013 11 25.Rev:5442. I have placed a copy of the HP_ELEMENTS.hpprgm in directories:

\Users\..\Appdata\Roaming\hp_prime, hp_prime
\Users\..\Appdata\Roaming\hp_prime, hp_prime_1,
\Users\..\Documents\HP Connectivity Kit\Calculators\MyCalc

With no success on that (or any other .hpprgm) d/l's. Other features of the ck work fine on both the virtual and real hp primes.

This version of the connectivity kit is junk dna from hp, as far as the outside world is concerned. Very frustrating.

Thank you,

-Dale-
Find all posts by this user
Quote this message in a reply
02-26-2014, 04:44 PM
Post: #14
RE: HP_ELEMENTS and scroll building block
When you put it in \Users\..\Appdata\Roaming\hp_prime, hp_prime
Does the program appear in the emulator's program editor (SHIT 1 keys) ?

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
02-26-2014, 09:30 PM
Post: #15
RE: HP_ELEMENTS and scroll building block
(02-26-2014 04:44 PM)Mic Wrote:  When you put it in \Users\..\Appdata\Roaming\hp_prime, hp_prime
Does the program appear in the emulator's program editor (SHIT 1 keys) ?

It is in emulator program catalog now. I guess I have to power cycle this computer in order to get things transferred? Wow, that isn't something to be proud of.

I ended up putting the program in three different directories, and so now I don't know which directory actually put the program in the emulator. I'll have to experiment in order to find that out.

Thank you for responding!

-Dale-
Find all posts by this user
Quote this message in a reply
02-27-2014, 06:50 AM
Post: #16
RE: HP_ELEMENTS and scroll building block
Exit and run again the emulator.

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
02-27-2014, 07:22 AM
Post: #17
RE: HP_ELEMENTS and scroll building block
(02-26-2014 04:44 PM)Mic Wrote:  (SHIT 1 keys) ?

I know quite a few people who call those keys that! Smile

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
02-27-2014, 07:45 AM
Post: #18
RE: HP_ELEMENTS and scroll building block
lol indeed i forgot the "f" but not intentionnaly Tongue

http://mic.nic.free.fr - Youtube - Facebook
Find all posts by this user
Quote this message in a reply
Post Reply 




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