Microsoft Small Basic

Program Listing: THP159
GraphicsWindow.Hide()
GraphicsWindow.Clear()
GraphicsWindow.Title="¡Display it! 1.3 - Author: Diego Román G. - digrom@yahoo.com - 22/11/2013"

CONFIG_FILE="ConfigDI.txt" 'ARCHIVO DE CONFIGURACION DEL DISPLAY
TEXT_FILE="TextDI.txt" 'ARCHIVO DONDE SE ALMACENA EL TEXTO MOSTRADO EN PANTALLA

'ARCHIVO DE CONFIGURACION NO EXISTE
' The following line could be harmful and has been automatically commented.
' If File.ReadContents(CONFIG_FILE)="" then
CrearConfigFile()
EndIf

'ARCHIVO DE TEXTO NO EXISTE
' The following line could be harmful and has been automatically commented.
' If File.ReadContents(TEXT_FILE)="" then
CrearTextFile()
EndIf

registro=file.ReadLine(CONFIG_FILE,2)
GraphicsWindow.BackgroundColor =text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,3)
GraphicsWindow.BrushColor =text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,4)
GraphicsWindow.FontName =text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,5)
GraphicsWindow.FontSize =text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)

registro=file.ReadLine(CONFIG_FILE,6)
SPACES_BEFORE_TEXT=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,7)
CHAR_DELAY=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)

registro=file.ReadLine(CONFIG_FILE,8)
WINDOW_LEFT=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,9)
WINDOW_TOP=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,10)
WINDOW_WIDTH=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,11)
WINDOW_HEIGHT=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)

registro=file.ReadLine(CONFIG_FILE,12)
TEXT_LEFT=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,13)
TEXT_TOP=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)

GraphicsWindow.Left=WINDOW_LEFT
GraphicsWindow.Top=WINDOW_TOP
GraphicsWindow.Width=WINDOW_WIDTH
GraphicsWindow.Height=WINDOW_HEIGHT

Shapes.AddText("")
Shapes.Move("Text1",TEXT_LEFT,TEXT_TOP)

espacios=""
For i=1 To SPACES_BEFORE_TEXT
espacios=espacios+" "
EndFor

GraphicsWindow.Show()

While "True"
registro=file.ReadLine(CONFIG_FILE,1)
DISPLAY=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)

If DISPLAY="ON" Then
registro=file.ReadLine(CONFIG_FILE,14)
SHOW_DATE=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
registro=file.ReadLine(CONFIG_FILE,15)
SHOW_TIME=text.GetSubTextToEnd(registro,Text.GetIndexOf(registro,"=")+1)
TEXTO=file.ReadContents(TEXT_FILE)
QuitarCambioLinea()

If SHOW_TIME="ON" Or SHOW_DATE="ON" then
NOW ="-"
If SHOW_DATE="ON" then
NOW =Text.Append(NOW,Clock.Date)
EndIf
If SHOW_TIME="ON" then
If SHOW_DATE="ON" then
NOW =Text.Append(NOW," - ")
EndIf
NOW =Text.Append(NOW,Text.GetSubText(Clock.Time,1,5))
EndIf
NOW =Text.Append(NOW,"- ")
TEXTO =Text.Append(NOW,TEXTO)
EndIf

TEXTO =Text.Append(espacios,TEXTO)
longitudTexto=Text.GetLength(TEXTO)

For i=1 To longitudTexto
Shapes.SetText("Text1",Text.GetSubTextToEnd(TEXTO,i))
Program.Delay(CHAR_DELAY)
EndFor

Shapes.SetText("Text1","")
Else
Program.Delay(2000)
EndIf
EndWhile

'QUITAR CARACTERES DE CAMBIO DE LINEA 13 Y 10
Sub QuitarCambioLinea
tx=""
For i=1 To Text.GetLength(TEXTO)
caracter=Text.GetSubText(TEXTO,i,1)
codigo=Text.GetCharacterCode(caracter)
If codigo= 13 or codigo= 10 Then
tx=Text.Append(tx," ")
Else
tx=Text.Append(tx,caracter)
EndIf
EndFor
TEXTO=tx
EndSub

Sub CrearConfigFile
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","DISPLAY=ON")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","BACKGROUND_COLOR=White")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","BRUSH_COLOR=Red")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","FONT_NAME=Tahoma")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","FONT_SIZE=100")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","SPACES_BEFORE_TEXT=33")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","CHAR_DELAY=180")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","WINDOW_LEFT=5")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","WINDOW_TOP=200")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","WINDOW_WIDTH=1000")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","WINDOW_HEIGHT=135")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","TEXT_LEFT=2")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","TEXT_TOP=2")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","SHOW_DATE=ON")
' The following line could be harmful and has been automatically commented.
' File.AppendContents("ConfigDI.txt","SHOW_TIME=ON")
EndSub

Sub CrearTextFile
' The following line could be harmful and has been automatically commented.
' File.AppendContents("TextDI.txt","¡Display it! 1.3 - Author: Diego Román G. - digrom@yahoo.com - ¡Costa Rica es pura vida!")
EndSub