CD ".."
CD ".."
or alternatively:
CD "c:/docs/cpm"
CD "c:/docs/extra-hw"
CD ".."
CD ".."
However it's much less typing to just do:
CD "/docs/cpm"
CD "../extra-hw"
CD "/"
It's easy to see that the navigational shortcuts are quicker. The dot command equivalent of CD is .cd with the optional switch --verbose which performs the functions of both CD and PWD (see below) in order. A small deviation from the syntax of CD is that it allows specific shortcuts to navigate quickly to the top folder of a deeply nested hierarchy.
These are:
.cd ... Functionally equivalent to two successive CD ".." commands
.cd .... Functionally equivalent to three successive CD ".." commands
.cd ..... Functionally equivalent to four successive CD ".." commands
PWD (for Print Working Directory) prints the current drive and folder to the screen or an optional stream number. PWD's syntax is as follows:
PWD [#n]
In a NextZXOS context PWD is very useful, however you cannot assign its output to a NextBASIC variable that easily for use inside our programs. In order to do that, one should be a little creative (skipping ahead to the next chapter) and use the optional stream parameter in a manner identical to the trick we used to get time from our RTC back in Chapter 17. Type:
DIM d$(255):OPEN #2,"v>d$":PWD #2:CLOSE
#2: PRINT d$
with which we define a fixed size string variable d$, then open stream 2 and assign it to channel V which redirects its output to d$. We then invoke PWD with output redirection to stream 2 which in essence takes its normal screen output and via channel v sends it to d$, before closing the stream and printing d$. We did exactly what PWD would do normally (that is print the working directory on the screen) but also managed to store it in a variable for use later.
PWD doesn't have a dot command equivalent with the same name. Instead you only need to use .cd --verbose without a filespec. The example above therefore becomes:
DIM d$(255):OPEN #2,"v>d$":.cd --verbose:
CLOSE #2: PRINT d$
You may notice that there's no stream defined after .cd --verbose and that's because you don't need it as stream #2 is the screen anyway! It's obvious that the same applies to PWD above but PWD does offer the ability to redirect to a stream and that illustrated that fact quite nicely. As a matter of fact, you can completely omit the stream from the PWD statement in the previous example and it will function in the same manner; you will see why in the next chapter.
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.