Home > CBM > BASIC > Keywords > Ti string | ||||||||||||||||||||||||||||||||||
The "token" is really just the ASCII codes for the characters "TI$"
In BASIC versions before 3.5, the timeHMS (when assigning) may include non-digits. In such a case, the value of that "digit" would be calculated as ASC(digit)-48. This gives the expected 0 ~ 9 for actual numeric digits, 10 for @, and 11 ~ 36 for unshifted letters A ~ Z (these are examples, any character is fine). In versions 3.5 and beyond, attempts to use non-numeric digits generate ILLEGAL QUANTITY ERROR. When assigning, if the seconds or minutes part of timeHMS exceed 59 then that part will be interpretted as zero (in version 1.0) or as value-60 (in versions 2+), and the next part (minutes or hours, respectively) will be increased by one. If the hours part exceeds 23, then the system time is set to zero (000000), after a Jiffy (see examples). In othe words, wrapping of values is broken in 1.0, and in other versions it works for seconds and minutes but not hours. If you attempt to assign a string of not exactly 6 characters, ILLEGAL QUANTITY ERROR is generated. Attempts to assign a numeric expression (a non-string) will generate TYPE MISMATCH ERROR. This string version of the system time is only accurate to the nearest second, although the system time is mainted by a "Jiffy Clock" which has a maximum resolution of 1/60 second. You can read this higher precision value with the numeric equivalant, TI, but you can not set that reserved variable. Like all BASIC variables, only the first two characters of the name are significant. So you may also use (and early documentation shows) TIME$ if you prefer (note the M and E are superfluous). On most (all?) of the CBM 8-bits, the system time is mainted by software in the KERNAL, even though some machines have hardware which is more reliable. In particular, delays in communicating with external devices (and a few internal operations) will cause the system time to "fall behind" reality (i.e., run slow). Generally the more I/O operations that take place, the less reliable the system time. The C128 has FAST and SLOW commands to change the CPU speed, and thus the speed of BASIC execution, but the Jiffy Clock works the same at either speed. Unfortunately, none of the CBM BASICs have a DATE$ variable or function. So you would need to periodically check the TI$ for "rollover" to detect a change in the date. Example:
© H2Obsession, 2014 |