Tuesday, June 26, 2012

Small Basic Spell Checker - 25 lines challenge


'Spell checker example - wxv722-2
'Uses Dictionary.GetDefinition(word) - Need internet access
'Harry Hardjono
'June 2012 - 25 line small basic challenge version
'
Str="abcdefghijklmnopqrstuvwxyz'ABCDEFGHIJKLMNOPQRSTUVWXYZ"
While (inputtext<>" ")
TextWindow.WriteLine("  ")
TextWindow.WriteLine("Enter your sentence: ")
inputtext=text.Append(TextWindow.Read()," ")
For i=1 To Text.GetLength(inputtext)
  If (Text.GetIndexOf(Str,Text.GetSubText(inputtext,i,1))=0) Then    'Not word
    If (Word<>"") Then
      If (Dictionary.GetDefinition(Word)="") Then  
      TextWindow.BackgroundColor="white"
      TextWindow.ForegroundColor="black"
      TextWindow.Write(Word)
      TextWindow.BackgroundColor="black"
      TextWindow.ForegroundColor="white"
      Else
      TextWindow.Write(Word)
      EndIf
      Word=""
    EndIf
    TextWindow.Write(Text.GetSubText(inputtext,i,1))
  Else 'Word
    Word=Text.Append(Word,Text.GetSubText(inputtext,i,1))
  EndIf
endfor
EndWhile

No comments: