HP Forums
HP_ELEMENTS and scroll building block - 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: HP_ELEMENTS and scroll building block (/thread-322.html)



HP_ELEMENTS and scroll building block - Miguel Toro - 01-04-2014 09:14 PM

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


RE: HP_ELEMENTS and scroll building block - Han - 01-05-2014 02:23 AM

Did anyone get this to actually run?


RE: HP_ELEMENTS and scroll building block - Miguel Toro - 01-05-2014 02:43 AM

(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


RE: HP_ELEMENTS and scroll building block - Han - 01-05-2014 02:51 AM

(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.


RE: HP_ELEMENTS and scroll building block - Mic - 01-05-2014 09:31 AM

No problem Miguel, you're welcome. I will try your changes.


RE: HP_ELEMENTS and scroll building block - NMihiylov - 02-22-2014 04:28 PM

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


RE: HP_ELEMENTS and scroll building block - Mic - 02-23-2014 06:27 AM

You can download the original program here :
http://mic.nic.free.fr/hp/Touch%20elements%20HP%20Prime.zip

Just send the .hpprgm to your calc.

Tell me if you still have a problem.


RE: HP_ELEMENTS and scroll building block - Miguel Toro - 02-23-2014 10:22 PM

(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


RE: HP_ELEMENTS and scroll building block - NMihiylov - 02-26-2014 02:23 AM

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


RE: HP_ELEMENTS and scroll building block - rprosperi - 02-26-2014 03:31 AM

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.


RE: HP_ELEMENTS and scroll building block - Mic - 02-26-2014 06:11 AM

Hello Nick,

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


RE: HP_ELEMENTS and scroll building block - toml_12953 - 02-26-2014 09:20 AM

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.


RE: HP_ELEMENTS and scroll building block - DrD - 02-26-2014 11:18 AM

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-


RE: HP_ELEMENTS and scroll building block - Mic - 02-26-2014 04:44 PM

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) ?


RE: HP_ELEMENTS and scroll building block - DrD - 02-26-2014 09:30 PM

(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-


RE: HP_ELEMENTS and scroll building block - Mic - 02-27-2014 06:50 AM

Exit and run again the emulator.


RE: HP_ELEMENTS and scroll building block - toml_12953 - 02-27-2014 07:22 AM

(02-26-2014 04:44 PM)Mic Wrote:  (SHIT 1 keys) ?

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


RE: HP_ELEMENTS and scroll building block - Mic - 02-27-2014 07:45 AM

lol indeed i forgot the "f" but not intentionnaly Tongue