<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 19 Jul 2007 00:16:19 +0100
From   : jgh@... (Jonathan Graham Harston)
Subject: re. Century and time on the Master 128.

>Message-ID: <006101c7c6f3$339c6ab0$0100000a@...>
 
<rafg1@...> wrote:
> James Fidell has kindly let me post a listing on his website
> of a different way to get the Master 128 to print the century
> correctly (or however you want to enter it into your machine).
 
Bear in mind that you should never attempt to read the time (on
any system!) and use the result blindly without checking it. The
following type of code has been standard since about 1986:
 
T$=TIME$:IFMID$(T$,14,1)<"8":T$=LEFT$(T$,11)+"20"+MID$(T$,14)
 
Even that could fall over if you are using a BASIC without the
'TIME$' function - any BASIC before BASIC IV. You should really
use code along the following lines:
 
DIM ctrl% 31:X%=ctrl%:Y%=X%DIV256
 
DEFFNtime:?X%=0:A%=14:CALL&FFF1:IF?X%=0:=""
X%?25=13:A%=VAL$(X%+4):$(X%+4)=RIGHT$("0"+STR$(A%AND31),2)
$(X%+11)=STR$(INTVAL$(X%+11)+(A%AND&E0)DIV2-100*(INTVAL$(X%+11)<1981))
X%?6=32:X%?15=46:=$X%
 
This also copes with the Master Compact incorrectly calculating
the year after 1996.
 
-- 
J.G.Harston - jgh@...                - mdfs.net/User/JGH
BBC IDE Hard Drive Interface - http://mdfs.net/Info/Comp/BBC/IDE
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>