Post Reply 
Python syntax time functions in cas
09-07-2019, 08:10 PM (This post was last modified: 09-08-2019 08:31 AM by StephenG1CMZ.)
Post: #4
RE: Python syntax time functions in cas
I assume that monotonic is not implemented.

There are four alternatives that could be used on the HP Prime if you allow PPL syntax within Python syntax.

First, how important is it to you that the solution is always monotonic? For those unfamiliar with the term, it means that the solution is always positive (i.e. Unlike most Ticks implementations, which eventually wrap around from a large positive to a large negative). Is that a requirement of your solution, or just something in the original code? Put simply, will a simple Ticks suffice or do you need perfection?

The PPL syntax available is:

TEVAL(this-code): Monotonic. Time in seconds to execute this-code (a function or command).
TiCKS() : Non-monotonic. Result in milliseconds.
Time() : Monotonic (when used together with Date() ). Formatted HH:MMConfusedS result.
time() : undocumented. Possibly seconds since switch-on - if so, monotonic.
(Update: time() with no parameters seems to return a numbers of seconds, but time(this code) can also be used, like TEVAL)

The easiest solution may be to use time(), but I have not found any documentation on it.

An alternative solution is to use Ticks.
This will work with the rest of the code unmodified if you can accept errors when Ticks wraps. You could add code to check whether stop is greater than start.

TEVAL is monotonic but requires the code to be restructured. Expected syntax is
TEVAL(this-code)/1_s
So you would need to wrap that Wait() inside the TEVAL.
The /1_s removes the units.

Time() is monotonic if used in conjunction with Date() (or if you avoid working at midnight) but the results are formatted as HHMMSS so the subtraction would need some parsing..
Code:
 
Def monotonic:
 RETURN time() 
Or:
Def monotonic:
 RETURN TICKS/1000.0 //not monotonic
Or:
Def monotonic:
 RETURN Time() //not seconds - needs formatting
Or:
Def thiscode:
 Wait(1)

TEVAL(this code)

Apologies for lower case/upper case difficulties: My spell checker is powerful.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Python syntax time functions in cas - StephenG1CMZ - 09-07-2019 08:10 PM



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