Post Reply 
HP Prime - Questions Spreadsheet and Python (Buffer overflow?)
04-08-2023, 02:14 PM
Post: #1
HP Prime - Questions Spreadsheet and Python (Buffer overflow?)
Hello!
My first posting here!
I bought a HP Prime calulator some weeks ago. My best calculator ever but also the most undocumented system ever. ;-) Not the source is the documenation (we have none) but the forum (I hope...)

1. I tried to make an application that creates a spreadsheet (or writes in the default spreadsheet which is the same). Then the application should terminate and just show the spreadsheet.
I can set cells with A1 := 23 or A2:= "A1 + A2", no problem. I can also use the Cell function to set cells or properties of cells. Like Cell(0, 1, 2):="My Name for Col 1"
That way I can set font, colors...

But how can I set the column width? I can do that manually but I found no way to set it in a program. Is there any?

2. As I said above, the program should terminate after it has created the spreadsheet. But I always get a message box at the end with the text "MyProg 0", or if return(1234) is the last statement with "MyProg 1234".
What can I do to stop that?

3. I like to use PYTHON. How nice is it to reuse already tested code. The documentation of HP Prime Python seems to be 0 bytes long? ;-)
I read many forum posts and managed to get some programs running.
There is this "PPL to PYTHON wrapper" - what a mess instead of just run the Python program alone. But ok - if you have that code just copy it in your program and go.

But now I have a question and I am clueless.
As I am German I need the "umlauts". äöüÄÖÜß - you might know. That should be no problem - the HP Prime seems to use UTF (UTF-16?) which can be typed in with the "char" key.
Here is a sample program.

Code:

#PYTHON mytest
myvar = "Hello Python - äöü"
print()
print(myvar)
#end 
 
EXPORT Test()
BEGIN
   local pplvar;
   print();
   pplvar:= "Hello PPL - äöü";
   print(pplvar);
   print("---END of PPL-----");
   PYTHON(mytest);
END;

When I run that program the printing in PPL is ok, but then I get random chars from the python print statement, which looks like a buffer overflow. See the screenshot, something was printed out that looks terrible. Something from inside the operating system. Its not the same each time when the program runs.

I used the emulator, I am a coward and do not want to crash my shining new HP Prime. ;-)

Question: How to use umlauts correctly in HP Prime Python? I tried something like
"# -*- coding: latin-1 -*-" as second line but without success.

Excuse my english. I hope its better than Google translate. ;-)

Greetings,
Thomas


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
04-10-2023, 03:54 AM
Post: #2
RE: HP Prime - Questions Spreadsheet and Python (Buffer overflow?)
in help search for ColWidth can be used to set the width of a column.

example SS.ColWidth(1):=100
Find all posts by this user
Quote this message in a reply
04-10-2023, 06:22 PM
Post: #3
RE: HP Prime - Questions Spreadsheet and Python (Buffer overflow?)
(04-10-2023 03:54 AM)Dougggg Wrote:  in help search for ColWidth can be used to set the width of a column.

example SS.ColWidth(1):=100

Thank you for your answer! Indeed the help is usefull. I found ColWidth() and Rowheight() there!
Find all posts by this user
Quote this message in a reply
Post Reply 




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