Talk:Multiplatform programming

From BeebWiki
Jump to: navigation, search

Calling OSBYTE 0 to test the platform works on DOS/Windows as the call is implemented as OSBYTE 135, which reads the character under the cursor. When a program starts it is almost always going to be in a state where the character under the cursor is a space, and as a result OSBYTE 0 returns 32. This has been used in many programs over the decades to indicate the platform is DOS/Windows with directory\file.ext pathnames.

Richard Russell, the author of Z80 and 80x86 BBC BASIC, has pointed out that in very rare circumstances, the character under the cursor could be a non-space. In all cases, though, it will be a printable character, and so will be 32 or greater. So, a better test for the DOS/Windows platform is os%>31 not os%AND32.

The article has been updated to do this better test. It actually uses AND-32 instead of >31 as that is slightly faster than a comparison, and keeps consistancy with using AND for the other tests.

Jgharston (talk) 20:59, 3 July 2016 (UTC)