Terminal control/Inverse video: Difference between revisions

Added ZX81 BASIC
(Added ZX81 BASIC)
Line 127:
echo 'bar'")
wait</lang>
 
==={{header|Sinclair ZX81 BASIC}}===
Inverse video is available from the keyboard (accessed with <code>SHIFT</code><code>9</code>), so the normal way to do this would be just
<lang basic>PRINT "FOOBAR"</lang>
but with the 'foo' in inverse video and the 'bar' in normal video.
 
If this won't work (say, if we may want to use inverse video with string variables rather than string literals), we can use a small subroutine—relying on the fact that the ZX81 character set uses the high bit of each character code to select normal or inverse video.
<lang basic>10 LET S$="FOO"
20 GOSUB 50
30 PRINT S$;"BAR"
40 STOP
50 FOR I=1 TO LEN S$
60 LET S$(I)=CHR$ (128+CODE S$(I))
70 NEXT I
80 RETURN</lang>
Note that this subroutine assumes the source string is not already in inverse video: if it could be, you will need to test each character before you attempt to convert it.
 
=== {{header|ZX Spectrum Basic}} ===
519

edits