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