agon-mos icon indicating copy to clipboard operation
agon-mos copied to clipboard

Date and Time not being updated

Open luisvolkyazul opened this issue 2 years ago • 8 comments

I was trying to use TIME within BBS BASIC and within the MOS itself to update it every time I power on the unit, however the values did not reflect what was entered. Not sure if it is user error. I am using MOS 2.0.0 VDP 2.0.1 This is the code I tried: 30 INPUT “Year:”year 40 INPUT “Month:”month 50 INPUT “Day:”day 60 INPUT “Hour:”hour 70 INPUT “Minutes:”minutes 80 INPUT “Seconds:”seconds 90 *TIME STR$(year) STR$(month) STR$(day) STR$(hour) STR$(minutes) STR$(seconds) 95 *TIME

luisvolkyazul avatar Nov 07 '23 22:11 luisvolkyazul

@luisvolkyazul Here is some RTC TIME-related BBC Basic code which you may find useful (taken from my "Agon Death House" project -- with line numbers removed):

:
MAXINT% = &3B9AC9FF
:
TIME = FN_SET_TIME(10, 30, 0)
PRINT FN_FORMAT_TIME(TRUE)
END

...

REM ::::::::::::::::::::::::::::::::
REM :: Prepend Zeroes To A Number ::
REM ::::::::::::::::::::::::::::::::
DEF FN_PAD_NUMBER(val%, len%)
LOCAL s$
s$ = STR$(val%)
:= STRING$(len% - LEN(s$), "0") + s$
:
REM ::::::::::::::::::::::::::::::::::::
REM :: Set the time of the simple RTC ::
REM :: in ticks (100 ticks / second)  ::
REM ::::::::::::::::::::::::::::::::::::
DEF FN_SET_TIME(hours%, minutes%, seconds%)
:= (hours% * 360000 + minutes% * 6000 + seconds% * 100) MOD MAXINT%
:
REM :::::::::::::::::::::::::::::
REM :: Format time as a String ::
REM :::::::::::::::::::::::::::::
REM addColons% may be TRUE or FALSE
DEF FN_FORMAT_TIME(addColons%)
LOCAL hours%, minutes%, seconds%, time%, r$
r$ = "":time% = TIME
hours% = time% DIV 360000
minutes% = (time% - hours% * 360000) DIV 6000
seconds% = (time% - hours% * 360000 - minutes% * 6000) DIV 100
r$ = FN_PAD_NUMBER(hours%, 2):IF addColons% THEN r$ = r$ + ":"
r$ = r$ + FN_PAD_NUMBER(minutes%, 2)
IF addColons% THEN r$ = r$ + ":"
r$ = r$ + FN_PAD_NUMBER(seconds%, 2)
:= r$
:
REM :::::::::::::::::::::::::::::::::::::::
REM :: Pause execution of the program    ::
REM :: for a number of ticks (1/100) sec ::
REM :::::::::::::::::::::::::::::::::::::::
DEF PROC_SLEEP(hundredth_seconds%)
LOCAL t
hundredth_seconds% = hundredth_seconds% + (hundredth_seconds% < 0) * -hundredth_seconds%
t = TIME
REPEAT UNTIL ((TIME - t) > hundredth_seconds%)
ENDPROC

tonedef71 avatar Nov 07 '23 23:11 tonedef71

Ok thank you for sharing this with me

On Tue, Nov 7, 2023 at 7:08 PM Tony DeFusco @.***> wrote:

@luisvolkyazul https://github.com/luisvolkyazul Here is some RTC TIME-related BBC Basic code which you may find useful (taken from my "Agon Death House https://github.com/tonedef71/agon-death-house" project -- with line numbers removed):

: MAXINT% = &3B9AC9FF : REM :::::::::::::::::::::::::::::::: REM :: Prepend Zeroes To A Number :: REM :::::::::::::::::::::::::::::::: DEF FN_PAD_NUMBER(val%, len%) LOCAL s$ s$ = STR$(val%) := STRING$(len% - LEN(s$), "0") + s$ : REM :::::::::::::::::::::::::::::::::::: REM :: Set the time of the simple RTC :: REM :: in ticks (100 ticks / second) :: REM :::::::::::::::::::::::::::::::::::: DEF FN_SET_TIME(hours%, minutes%, seconds%) TIME = (hours% * 360000 + minutes% * 6000 + seconds% * 100) MOD MAXINT% := TIME : REM ::::::::::::::::::::::::::::: REM :: Format time as a String :: REM ::::::::::::::::::::::::::::: REM addColons% may be TRUE or FALSE DEF FN_FORMAT_TIME(addColons%) LOCAL hours%, minutes%, seconds%, time%, r$ r$ = "":time% = TIME hours% = time% DIV 360000 minutes% = (time% - hours% * 360000) DIV 6000 seconds% = (time% - hours% * 360000 - minutes% * 6000) DIV 100 r$ = FN_PAD_NUMBER(hours%, 2):IF addColons% THEN r$ = r$ + ":" r$ = r$ + FN_PAD_NUMBER(minutes%, 2) IF addColons% THEN r$ = r$ + ":" r$ = r$ + FN_PAD_NUMBER(seconds%, 2) := r$ : REM ::::::::::::::::::::::::::::::::::::::: REM :: Pause execution of the program :: REM :: for a number of ticks (1/100) sec :: REM ::::::::::::::::::::::::::::::::::::::: DEF PROC_SLEEP(hundredth_seconds%) LOCAL t hundredth_seconds% = hundredth_seconds% + (hundredth_seconds% < 0) * -hundredth_seconds% t = TIME REPEAT UNTIL ((TIME - t) > hundredth_seconds%) ENDPROC

— Reply to this email directly, view it on GitHub https://github.com/breakintoprogram/agon-mos/issues/113#issuecomment-1800345157, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4D2SM64EJRGMDFLWZ2PXCLYDK5ORAVCNFSM6AAAAAA7B5KPZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBQGM2DKMJVG4 . You are receiving this because you were mentioned.Message ID: @.***>

luisvolkyazul avatar Nov 07 '23 23:11 luisvolkyazul

this line won't work:

90 *TIME STR$(year) STR$(month) STR$(day) STR$(hour) STR$(minutes) STR$(seconds)

reason being is that whatever is after the * is just passed thru to MOS as a star command to be interpreted. the STR$(year) etc won't get evaluated but instead gets passed as-is.

to do what you're after you need to construct a string, and pass that to the OSCLI command.

this therefore should become:

90 OSCLI("TIME " + STR$(year) + " " + STR$(month) + " " + STR$(day) + " " + STR$(hour) + " " + STR$(minutes) + " " + STR$(seconds))

stevesims avatar Nov 11 '23 15:11 stevesims

Ok, thanks for the clarification.

On Sat, Nov 11, 2023 at 11:48 AM Steve Sims @.***> wrote:

this line won't work:

90 *TIME STR$(year) STR$(month) STR$(day) STR$(hour) STR$(minutes) STR$(seconds)

reason being is that whatever is after the * is just passed thru to MOS as a star command to be interpreted. the STR$(year) etc won't get evaluated but instead gets passed as-is.

to do what you're after you need to construct a string, and pass that to the OSCLI command.

this therefore should become:

90 OSCLI("TIME " + STR$(year) + " " + STR$(month) + " " + STR$(day) + " " + STR$(hour) + " " + STR$(minutes) + " " + STR$(seconds))

— Reply to this email directly, view it on GitHub https://github.com/breakintoprogram/agon-mos/issues/113#issuecomment-1806849041, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4D2SMZ5BMCQPBADATMA7Q3YD6M3JAVCNFSM6AAAAAA7B5KPZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBWHA2DSMBUGE . You are receiving this because you were mentioned.Message ID: @.***>

luisvolkyazul avatar Nov 11 '23 16:11 luisvolkyazul

Ok tried the change and think I understand the logic behind it...however I'm getting the following: No such variable at line 90 image

luisvolkyazul avatar Nov 11 '23 16:11 luisvolkyazul

Ok tried the change and think I understand the logic behind it...however I'm getting the following: No such variable at line 90 image

In line 90, I see that you have SRT$ a couple of times in place of STR$.

tonedef71 avatar Nov 11 '23 16:11 tonedef71

@luisvolkyazul let me know if that answers your question and if it does I'l close this card.

breakintoprogram avatar Nov 11 '23 18:11 breakintoprogram

Not able to get it working yet.

luisvolkyazul avatar Nov 13 '23 02:11 luisvolkyazul