Ongelma on se, että en saa luettua tiedostosta kuin yhden rivin readline komennolla.
Kääntäjä lukee koodin editor.txt tiedostosta ja käännetty koodi ilmestyy Program.txt tiedostoon!
Eli ohjelma osaa kääntää ensimmäisen rivin koodista, mutta ei sen enempää
Tossa "BETA" koodi:
Code: Select all
SCREEN 400,300
SetWindow "SimpleBasic--COMPILING!"
f=OpenToRead("Editor.txt")
f2=OpenToWrite("Program.txt")
For i=1 To 100
teksti$=ReadLine(f)
If InStr(teksti$,"Print")=>0 Then
komento$="Print"
komento2$="Print"
EndIf
If InStr(teksti$,"Title")=>0 Then
komento$="Title"
komento2$="SetWindow"
ElseIf InStr(teksti$,"If")=>0 Then
komento$="If"
komento2$="If"
ElseIf InStr(teksti$,"Then")=>0 Then
komento$="Then"
komento2$="Then"
ElseIf InStr(teksti$,"Goto")=>0 Then
komento$="Goto"
komento2$="Goto"
ElseIf InStr(teksti$,"Cls")=>0 Then
komento$="Cls"
komento2$="Cls"
ElseIf InStr(teksti$,"Put")=>0 Then
komento$="Put"
komento2$="Dot"
ElseIf InStr(teksti$,"Key")=>0 Then
komento$="Key"
komento2$="GetKey"
ElseIf InStr(teksti$,"Wait")=>0 Then
komento$="Wait"
komento2$="Wait"
ElseIf InStr(teksti$,"Color")=>0 Then
komento$="Color"
komento2$="Color"
ElseIf InStr(teksti$,"Pos")=>0 Then
komento$="Pos"
komento2$="Locate"
ElseIf InStr(teksti$,"Input")=>0 Then
komento$="Input"
komento2$="Input"
EndIf
uusi$=Replace (teksti$,komento$,komento2$)
WriteLine f2,uusi$
Next i
CloseFile f
CloseFile f2
KOMENNOT:
If
Then
Goto
Cls
Put
Title
Key
Wait
Color
Pos