Filing system structure
On almost every platform that BBC BASIC has been ported to you can call
OSBYTE 0 to find out what the host hardware is, and from that
what capabilities the host hardware has. This can be useful to set various
program defaults that cannot be done by making other calls (for instance,
any system might have a mouse - just use
ADVAL(8) and see happens). By coincience or design, over
the years the value returned forms a bitmap that makes for convenient
A%=0:X%=1:os%=((USR&FFF4)AND&FF00)DIV256 IF (os% AND -24)=0 THEN paths are :drive.directory.file/ext IF (os% AND -24)=8 THEN paths are directory/file.ext IF (os% AND -32) THEN paths are d:directory\file.ext IF (os% AND -24)=0 THEN Directory seperators are '.' IF (os% AND -24)=8 THEN Directory seperators are '/' IF (os% AND -32) THEN Directory seperators are '\' IF (os% AND -24)=0 THEN Extension seperators are '/' IF (os% AND -24) THEN Extension seperators are '.' IF (os% AND -24)=0 THEN Drive specifiers are :d IF (os% AND -24) THEN Drive specifiers are d:
You can then use these tests in platform-independant code, such as in the following example:
BBC API entries
On most implementations of BBC BASIC, CALL and USR can be used to access the BBC API at &FFxx. Testing for PAGE<&FFFF will tell you if the API is available, so you can use code such as:
REM Read object information: IF PAGE<&FFFF THEN $name%=A$:?X%=name%:X%?1=name%DIV256:A%=5:ftype%=(USR&FFDD)AND&FF REM Write bytes to file: ?X%=channel:X%!1=address,X%!5=count:A%=gbpb_wr IF PAGE<&FFFF THEN CALL &FFD1 ELSE REPEAT:BPUT#?X%,?(X%!1):X%!1=X%!1+1: X%!5=X%!5:UNTIL X%!5=0
- Filename translation
- Pathname translation
- Filename character mapping
- The generic FileIO library uses these techniques.
- The FName BASIC library translates simple filenames.
- The Filename BASIC library translates full pathnames.
- The ProgEnv library sets
os%and also returns other platform environment parameters such as the command line and the run filename.