DIM #n
DIM #n TO [%]var
This command returns the size (in characters or bytes) of stream n. Whatever applies to the RETURN #...TO variant of POINT # applies to the DIM #...TO as well. Variable var stores the size of the stream. As with RETURN #...TO above, var can be an integer variable in which case the same warning as with the previous section applies.
GO TO #n, [%]pos
This command sets the current position of stream n to position pos. Let's see how the previous three commands all tie together by experimenting with browser.cfg:
10 OPEN #4,"/nextzxos/browser
.cfg"
20 REM "i>" is optional since
the filename is longer
than 1 character
30 DIM #4 TO %a: REM Get
filesize and put it in %a
40 RETURN #4 TO %b: REM Get
current location and put
it in %b
50 PRINT "You're in byte: ";
%b ; " of "; %a
60 GO TO #4, %a/2: REM Move
to the middle of the file
70 RETURN #4 TO %b: REM Get
current location and put
it in %b
80 PRINT "Now, you're in
byte: "; %b ; " of "; %a
90 CLOSE #4
NEXT #n TO [%]var
This command gets the next character of input from stream n. As with POINT # and DIM #, if used with the TO modifier it also stores it in the variable var. If used on the standard k channel, this is similar to the INKEY$ function, except that it always waits for the next character to become available (ie on the k channel, it waits for a keypress). Using an integer variable here, is safe as the command gets one character at a time ergo one byte so its value will never exceed 255.
You can use this command instead of INPUT # on all channels that accept input otherwise they're very much identical in function.
Try this little program which will turn your ZX Spectrum Next into a typewriter:
10 NEXT #0 TO x
20 PRINT CHR$(x);
30 GO TO 10
Alternatively you could change line 10 to:
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.