Post Reply 
Python oddities
05-05-2021, 10:24 PM
Post: #3
RE: Python oddities
(05-05-2021 08:56 PM)toml_12953 Wrote:  Where is PPL-Changes + python.odt?

When I try to export the program name (hat), I get an error at

Export hat()

It was in Tim's announcement

I think the syntax is not really obvious, could you post your code? Perhaps I can help. There are two distinct structures in the mentioned document, either one works, but don't mix them.

BTW, I took the freedom to tailor your Pyhat a bit. There is no improvement, I just played a little bit with Python things.
from hpprime import *
from math import *
t0 = eval("ticks()") # Save the current clock count for timing program
# Clear screen
# Start program proper
p=160; q=120
xp=144; xr=1.5*3.1415927
yp=56; yr=1; zp=64
xf=xr/xp; yf=yp/yr; zf=xr/zp
for zi in range(-q,q+1):
  if zi>=-zp and zi<=zp:
    zt=zi*xp/zp; zz=zi
    # Draw one cross-section of figure
    for xi in range(-xl,xl+1):
      xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
#      eval("wait(0.001)")
      if y1!=0:
        line(0,x1,230-y1+1,x1,230,bg) # Erase points below current point
#    eval("wait(0.001)")
t = eval("ticks()")-t0
# Wait for key and print elapsed time
t = t/1000
print(t," seconds")
Export pyhat(a)

This has to be copied into an PPL program to work. Then it can be called by "pyhat(0)", any number instead of "0" will do.

Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
Python oddities - Guenter Schink - 05-05-2021, 07:41 PM
RE: Python oddities - toml_12953 - 05-05-2021, 08:56 PM
RE: Python oddities - Guenter Schink - 05-05-2021 10:24 PM
RE: Python oddities - toml_12953 - 05-06-2021, 12:28 AM

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