X=$left$|(_d,2){Y=left$$|(_d,2)~Y<>X|x=!Y!%12~x=0|x=12]B=C[x|B=B+@BONG |]?_tB|]X=Y
确实需要更改代码文字($
)的标记并实现子字符串功能(left$(x,y)
可以更短)。
内部工作原理:
In the first part, we want to set X$ to the hour-component
of our system's time. The DATE is implemented in QBIC, but
Substring (LEFT$, RIGHT$ and MID$ in QBasic) is not (yet).
We need to use the QBasic LEFT$ function, and QBIC can do
that using a 'code literal': everything from '$' to '|'
is not parsed by QBIC but passed on to QBasic.
X= Set X$ to
$left$|( the leftmost (note the '$' and '|' for the code literal)
_d,2) 2 characters of TIME$ (hh:mm format)
{ DO - infinite loop
Y=left$$|(_d,2) Set Y$ in the same way
~Y<>X If Y$ is not equal to X$ the hour has changed
|x=!Y!%12 THEN set x to the modulo 12 of Y$ cast to number
~x=0|x=12] If Y% happens to be divisible by 12, set x to 12
B=C Clear B$ (c$ never gets assiged a value)
[x|B=B+@BONG |] For the given number of hours, add "BONG " to B$
?_tB| Print B$, trim the trailing space
] end if
X=Y Update X$
<DO LOOP is implicitly closed>
更新(NC):$
在QBIC指令集中不再使用,因此现在可以将其自由地用作QBasic的代码,而无需代码文字。在这种情况下,它将节省4个字节,从而使QBIC达到78个字节:
X=left$(_d,2){Y=left$(_d,2)~Y<>X|x=!Y!%12~x=0|x=12]B=C[x|B=B+@BONG `]?_tB|]X=Y