OSBYTE 0,<>0 Host Values
========================
| Host Values | Pathnames
-----+-----------------------------------------+------------------------------------------
| 0 1 2 3 4 5 6 7 | :d.$.directory.filename/ext
| Elk BBC B+ M128 MET Comp Arc Spr | :drv.$.directory.filename/ext
eol$ | 13 13 13 13 13 10 10 |
-----+-----------------------------------------+------------------------------------------
| 8 9 10 11 12 13 14 15 | d:/directory/filename.ext
| Unix 6x09 |
eol$ | 10 13 |
-----+-----------------------------------------+------------------------------------------
| 16 17 18 19 20 21 22 23 | :d.directory.filename/ext
| 6x09 | :drv.$.directory.filename/ext
eol$ | 13 |
-----+-----------------------------------------+------------------------------------------
| 24 25 26 27 28 29 30 31 | d:/directory/filename.ext
| C64 TI Ams ZXS | d:filename.ext
eol$ | 13 13+10 13 | drv:filename.ext
-----+-----------------------------------------+------------------------------------------
| 32 33 34 35 36 37 38 39 | d:\directory\filename.ext
| DOS |
eol$ | 13+10 |
-----+-----------------------------------------+------------------------------------------
Host Bitmap
-----------
xx0x0xxx - :d.directory.filename/ext
xx0x1xxx - d:/directory/filename.ext
nnnxxxxx - d:\directory\filename.ext
1xxxxxxx - translated host value
Output end-of-line sequence
---------------------------
Partial formula:
eol$=CHR$(10-3*(os%<6)):IFos%>31:eol$=CHR$13+CHR$10
Tube Command bitmap
-------------------
x00xxxx0 - BBC - :d.directory.filename/ext
x01xxxx0 - Unix - d:/directory/filename.ext
x10xxxx0 - DOS - d:\directory\filename.ext
x11xxxx0 -
mos_byte 0 returns:
X%=(host%AND&57)OR(client%*16-(client%AND8))
IFX%<>host%:X%=X%OR&80
=0
n n*16 nAND8 n*16-(nAND8)
00 - 0 - 000 - 0 0 0 0
01 - 1 - 001 - 1 16 8 8
10 - 2 - 100 - 4 32 0 32
11 - 3 - 101 - 5 48 8 40
See beebWiki Multiplatform programming
[[Title:Multiplatform programming]]
[[Category:Programming]]
[[Category:BASIC]]
On almost every platform that BBC BASIC has been ported to you can call
[[OSBYTE_&00|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(7)'''
,
'''ADVAL(8)'''
and see happens). By coincience or design, over
the years the value returned forms a bitmap that makes for convenient
testing.
A%=0:X%=1:os%=((USR&FFF4)AND&FF00)DIV256
IF(os%AND32)=0 THEN Filing system calls to &FFxx are allowed
IF(os%AND40)=0 THEN Directory seperators are '.'
IF(os%AND40)=8 THEN Directory seperators are '/'
IF(os%AND32) THEN Directory seperators are '\'
IF(os%AND40)=0 THEN Extension seperators are '/'
IF(os%AND40) THEN Extension seperators are '.'
IF(os%AND40)=0 THEN Drive specifiers are :d
IF(os%AND40) THEN Drive specifiers are d:
You can then use these tests in platform-independant code, such as in the following examples:
d$=".":s$="/":IF(os%AND40):d$="/":s$=".":IF(os%AND32):d$="\"
filename$=dir$+d$+name$+s$+ext$
DEFPROCf_gbpb(A%,chn%,adr%,num%,ptr%)
?X%=chn%:X%!1=adr%:X%!5=num%:X%!9=ptr%
IF(os%AND32)=0:CALL&FFD1:ENDPROC
IF(A%AND1):PTR#chn%=ptr%
REPEAT:IF((A%-1)AND2):?adr%=BGET#chn% ELSE BPUT#chn%,?adr%
adr%=adr%+1:num%=num%-1:UN.num%=0 OR (EOF#chn% AND ((A%-1)AND2))
X%!1=adr%:X%!5=num%:X%!9=PTR#chn%
ENDPROC
==See also==
* The [http://mdfs.net/blib generic FileIO] library uses these techniques.
* The [http://mdfs.net/blib ProgEnv] library sets '''os%'''
and also returns other platform environment parameters such as the command line and the run filename.
[[User:Jgharston|Jgharston]] 18:51, 29 November 2010 (UTC)
Program Environment
os%
paths eol
0 1 2 3 4 5 6 7 Acorn :d.$.dir.file/ext
8 9 10 11 12 13 14 15 Unix /dir/file.ext CHR$10
16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31
32 + DOS d:\dir\file.ext CHR$13+CHR$10
Notes
-----
If standard eol$ on C64 is LF, consider using 8-15 range.
C64 doesn't have LF! Cursor down is CHR$17! So 28 is in correct range.