ever is via NextBASIC and it's the aptly named function TIME$. Let's examine both as the first method can be used for several other NextZXOS facilities that return information for which NextBASIC doesn't yet have a specialised keyword.

We need to use the NextZXOS facilities of Channels and Streams (which we will explore in Chapter 20) and specifically, Channel v (which opens a stream to a fixed sized variable t$)

DIM t$(100):OPEN #2,"v>t$":.TIME
:CLOSE #2:PRINT t$

then by string slicing t$ as seen in depth in Chapter 7, we can extract the information we need to use .time (or .date) in our programs.

TIME$

Function TIME$ does the exact thing as the example above but in a much cleaner way and moreover, the user does not need to get only time or date separately as with TIME$ you get them both simultaneously.

For example typing:

PRINT TIME$

will return a string of the format yyyy-mm-dd hh:mm:ss like:

2023-05-10 16:55:32

which is obviously easy to slice and get the information from.

Now we already discussed that a frame lasts a different amount of time depending on if your computer is running at 50Hz or at 60Hz. Here's a revised program that finds out what frequency you're running on first and then tests against the amount of PAUSE frames you'll request. Do not pay attention to the REG function, we will explain it in Chapter 22.

 10 sp=REG 5&@100>>2
 20 PRINT "I'm running at
    ";sp?("50","60");Hz"
 30 INPUT "How many PAUSE
    frames? ";f
 40 PRINT
 50 PROC gettime() TO H1,M1,S1
 60 PRINT "Testing at
    ";sp?("50","60"); "Hz
    started
    at:";H1;":";M1;":";S1
 70 TIME
 80 PROC PerfTest(f)
 90 PRINT '"PerfTest() took
    ";TIME;" frames against
    desired ";f;" PAUSE
    frames."
100 PROC GetTime() TO H2, M2,
    S2

ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.