Spanish <--> English with GUI frontend.
' ************************************************************
' ** **
' ** diccionarioEsEn Aug 2019 tenochtitlanuk **
' ** singleScreenVersion **
' ************************************************************
nomainwin
' get dictionary into a string variable so can use instr(
open "diccionario3.txt" for input as #fIn
dict$ =input$( #fIn, lof( #fIn))
close #fIn
' file is a series of words as follows--
' line-separator is Linyc chr$( 10)
' note 4 ( or 8) leading spaces
' spanish word/English def'n/part of speech..m/f..extra comments
' LF
' corazónLF
' the center of an objectLF
' {m}LF
'
' Uses 'instr(' to find all occurrences of asn English word in the English part
' or Spanish word in the Spanish part...
' and shows all matching ones.
WindowWidth = 560
WindowHeight = 660
statictext #w.st1, "", 90, 5, 300, 40
texteditor #w.te1, 10, 45, 530, 440
button #w.b1, "-Sp2En-->", [S2E], LR, 150, 70, 140, 35
button #w.b2, "-En2Sp-->", [E2S], LR, 470, 70, 140, 35
button #w.b3, "Clear", [clrE], LR, 300, 70, 110, 35
open "Translator" for window as #w
#w "trapclose quit"
#w "font Times_New_Roman 14 bold"
#w.te1 "!font 8"
wait
end
[S2E]
#w.st1 "English"
#w.te1 "!contents? E$"
#w.te1 ""
wordLength =len( E$)
E$ =" " +left$( E$, len( E$) -2) ' look for keyword- leading space so not part of longer word
' omit the LF and space..
[N]
i =instr( dict$, E$, i +1)
if i =0 then wait
M$ =mid$( dict$, i +wordLength -1, 1)
I =instr( "abcdefghijklmnopqrstuvwxyz", M$)
if I <>0 then goto [N] ' we've got back beyond word
' text req'd goes back to ''; forward to ''.
j =i ' don't want he ' '.
[back0] ' find start of part to print
scan
j =j -1
m$ =mid$( dict$, j, 3)
if m$ <>"" then [back0]
j =j +12
k =i
[fwd0] ' find end of part to print
scan
k =k +1
m$ =mid$( dict$, k, 4)
if m$ <>"" then [fwd0]
#w.te1 mid$( dict$, j, k -j)
if i <>0 then [N]
wait
[E2S]
#w.st1 "Español"
#w.te1 "!contents? E$"
#w.te1 ""
wordLength =len( E$)
E$ =" " +left$( E$, len( E$) -2) ' look for keyword- leading space so not part of longer word
' omit the LF and space..
if right$( E$, 1) ="." then E$ =left$( E$, len( E$) -1) ' if terminated by a full stop..
[L]
i =instr( dict$, E$, i +1)
if i =0 then wait
M$ =mid$( dict$, i +wordLength -1, 1)
I =instr( "abcdefghijklmnopqrstuvwxyz", M$)
if I <>0 then goto [L] ' we've got back beyond word
' text req'd goes back to ''; forward to ''.
j =i ' don't want he ' '.
[back] ' find start of part to print
scan
j =j -1
m$ =mid$( dict$, j, 3)
if m$ <>"" then [back]
j =j +12
k =i
[fwd] ' find end of part to print
scan
k =k +1
m$ =mid$( dict$, k, 4)
if m$ <>"" then [fwd]
#w.te1 mid$( dict$, j, k -j)
if i <>0 then [L]
wait
[clrE]
#w.te1 "!cls"
#w.te1 "!setfocus"
wait
sub quit h$
close #h$
end
end sub