How to resolve the algorithm Terminal control/Inverse video step by step in the BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Terminal control/Inverse video step by step in the BASIC programming language

Table of Contents

Problem Statement

Display a word in inverse video   (or reverse video)   followed by a word in normal video.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Terminal control/Inverse video step by step in the BASIC programming language

Source code in the basic programming language

INVERSE:?"ROSETTA";:NORMAL:?" CODE"

      COLOUR 128        : REM Black background
      COLOUR 15         : REM White foreground
      PRINT "Inverse";
      COLOUR 128+15     : REM White background
      COLOUR 0          : REM Black foreground
      PRINT " video"


      inverse$ = CHR$(17)+CHR$(128)+CHR$(17)+CHR$(15)
      normal$ = CHR$(17)+CHR$(128+15)+CHR$(17)+CHR$(0)
      PRINT inverse$ + "Inverse" + normal$ + " video"


5 rem inverse video
10 print chr$(18);"reverse on";chr$(146);" reverse off"
20 print
25 rem newline (cr) also terminates reverse mode
30 print chr$(18);"this is reversed... ";:print "so is this."
40 print
50 print chr$(18);"this is reversed... ":print "this is not."
60 print 
70 print chr$(18);"this is reversed... ";chr$(13);"this is not."

Color 0, 15 ' usa los colores blanco (fondo) y negro (primer plano)
Locate 2, 2 : Print "Video inverso"
Color 15, 0 ' usa los colores negro (fondo) y blanco (primer plano)
Locate 3, 2 : Print "Video normal"
Sleep

10 CALL &bb9c:PRINT "inverse";
20 CALL &bb9c:PRINT "normal"

If OpenConsole()
  ConsoleColor(0, 15) ;use the colors black (background) and white (forground)
  PrintN("Inverse Video")
  ConsoleColor(15, 0) ;use the colors white (background) and black (forground)
  PrintN("Normal Video")
  
  Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
  CloseConsole()
EndIf

' ---------- foo is reverse --------------
x$ = shell$("tput mr
echo 'foo'")

' ---------- bar is normal --------------
x$ = shell$("tput me     
echo 'bar'")
wait

PRINT "FOOBAR"


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


print color("black","white") "Video inverso"
// o también
print reverse "Video inverso"

print color("white","black") "Video normal"

10 INVERSE 1
20 PRINT "FOO";
30 INVERSE 0
40 PRINT "BAR"


  

You may also check:How to resolve the algorithm Delete a file step by step in the Run BASIC programming language
You may also check:How to resolve the algorithm Queue/Definition step by step in the Java programming language
You may also check:How to resolve the algorithm Catalan numbers/Pascal's triangle step by step in the MATLAB / Octave programming language
You may also check:How to resolve the algorithm AVL tree step by step in the Nim programming language
You may also check:How to resolve the algorithm Topswops step by step in the FreeBASIC programming language