The BASIC TIME$ variable

SYS 64738
The_Other_Shaun_B
Member
Member
Posts: 12
Joined: Sat Feb 12, 2022 2:00 pm
Contact:

The BASIC TIME$ variable

Post by The_Other_Shaun_B »

Okay guys,

Anyone know what's going on here?

Regards,

Shaun.
Attachments
time$.png


User avatar
eslapion
Active Member
Active Member
Posts: 1215
Joined: Mon Jul 20, 2015 10:11 am
Location: Canada
Contact:

Re: The BASIC TIME$ variable

Post by eslapion »

I do.

TIME$ is the long version of the TI$ variable used in the OS of all Commodore BASIC implementations. Commodore BASIC only consider the first two characters in the name of variables.

When you turn on your PET/VIC-20/C64, TI$ contains "000000" and is incremented by 1 every second. However when 000059 is reached, the next value is 000100 so the content is 2 digits for hours, 2 digits for minutes and 2 digits for seconds.

You can force this variable to an actual time of day value by typing TI$="051719" and the system will keep increasing this clock value accordingly. Inputting letters, however gives unpredictable results.
Wealth, like happiness, is never attained directly. It comes as a by-product of providing a useful service. -Harland D. Sanders
The_Other_Shaun_B
Member
Member
Posts: 12
Joined: Sat Feb 12, 2022 2:00 pm
Contact:

Re: The BASIC TIME$ variable

Post by The_Other_Shaun_B »

Hi,

Thanks for the explanation. I already knew that TIME$ and TI$ are equivalent, but I just wondered why I could enter any string value without an "illegal quantity error"

Regards,

Shaun.
User avatar
Zippy Zapp
Member
Member
Posts: 206
Joined: Tue Jul 21, 2015 6:52 pm
Location: USA
Contact:

Re: The BASIC TIME$ variable

Post by Zippy Zapp »

IIRC, you only get an Illegal Quantity Error if you set it to less than 6 digits/characters. IE: TI$="12345"
Commodore - Changing the world 8 bits at a time.
Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 5 guests