Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date and Time not being updated #113

Open
luisvolkyazul opened this issue Nov 7, 2023 · 8 comments
Open

Date and Time not being updated #113

luisvolkyazul opened this issue Nov 7, 2023 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@luisvolkyazul
Copy link

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

@tonedef71
Copy link

tonedef71 commented Nov 7, 2023

@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

@luisvolkyazul
Copy link
Author

luisvolkyazul commented Nov 7, 2023 via email

@stevesims
Copy link
Contributor

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))

@luisvolkyazul
Copy link
Author

luisvolkyazul commented Nov 11, 2023 via email

@luisvolkyazul
Copy link
Author

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

@tonedef71
Copy link

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$.

@breakintoprogram breakintoprogram added the help wanted Extra attention is needed label Nov 11, 2023
@breakintoprogram
Copy link
Owner

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

@luisvolkyazul
Copy link
Author

Not able to get it working yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: No status
Development

No branches or pull requests

4 participants