'Speller Speech Editor
Setup:
  Window 1,"Speller Speech Editor",(50,50)-(590,150),30
  On Window Gosub Ext
  Window On
InitVars:
  dim voice%(8)
  for i=0 to 8
    read voice%(i)
  next
  data 80,0,160,0,22900,64,10,0,0
  Sub Speak(text$)
    shared voice%
    Say Translate$(Text$),voice%
  END SUB
  dim phr$(17)
  for sp=1 to 17
    read phr$(sp)
  next sp
  Data Try,"Now, Spell","Next, Try","Spell The Word","Ready. Spell"
  Data "Right","That's Right","Correct","That's it!"
  Data "Sorry, the correct spelling of"
  Data is,"All Done","Perfect score","You scored ten out of ten!"
  Data "You Scored","Out Of Ten","Goodbye."
  phr=1
  Sub Update
    Shared Phr$,phr
    Gadget Close 1
    Gadget 1,1,phr$(phr),(13,57)-(528,70),2
  End Sub
  Sub ClearText
    Line (7,4)-(523,49),0,bf
  End Sub
  Sub Msg
    Shared phr
    Call ClearText
    If phr=1 or phr=2 or phr=3 or phr=4 then
      Locate 2,2:?"This is one of four random phrases that Speller"
      Locate 3,2:?"uses when it's asking you to spell a word."
      Locate 5,2:style 2:?"Examples";:style 0:?": Spell, try to spell, now try, etc."
    End if
    If Phr=5 then
      Locate 2,2:?"This is the phrase that Speller uses when it asks you to"
      Locate 3,2:?"spell the first word.  Since it's the first thing that"
      Locate 4,2:?"Speller says, it could include an welcoming message."
      Locate 6,2:style 2:?"Example";:style 0:?": Welcome to Speller.  Let's start with, etc."
    End If
    If phr=6 or phr=7 or phr=8 or phr=9 then
      Locate 2,2:?"This is one of four things that Speller will say if"
      Locate 3,2:?"the user correctly spells the word."
      Locate 5,2:style 2:?"Examples";:style 0:?": Correct!  That's Right!  Good!"
    end if
    If Phr=10 then
      Locate 2,2:?"This is what Speller says if the user incorrectly"
      locate 3,2:?"spells the word.  It should be something like"
      locate 4,2:?"'Sorry, the correct spelling of' because after Speller"
      locate 5,2:?"says this, it will spell the word itself."
      locate 6,2:style 2:?"Example";:style 0:?": No, the correct spelling of"
    End If
    If Phr=11 then
      locate 2,2:?"This is usually one word that Speller uses in this way:"
      locate 3,2:?"The correct spelling of word ";:color 2:?"_is_";:color 1:?" w-o-r-d."
      locate 4,2:?"It doesn't have to be one word, however, but should be"
      locate 5,2:?"something similar."
    end if
    if phr=12 then
      locate 2,2:?"This is what Speller says when the spelling is finished."
      locate 4,2:style 2:?"Examples";:style 0:?": Finished, all done, etc."
    end if
    if phr=13 then
      locate 2,2:?"This is one of two things Speller says when the user gets all"
      locate 3,2:?"of the words correct.  This should be some sort of"
      locate 4,2:?"congratulatory message."
      locate 6,2:style 2:?"Examples";:style 0:?": Hooray, Nicely Done, Congrats, etc.
   end if
    if phr=14 then
      locate 2,2:?"This the second thing Speller says when the user gets all"
      locate 3,2:?"of the words right.  This should be something that tells"
      locate 4,2:?"the user the actual";:color 2:?" number";:color 1:?" that they scored."
      locate 6,2:Style 2:?"Example";:style 0:?": You scored a full ten out of ten!"
    end if
    if phr=15 then
      locate 2,2:?"This is what Speller says when it tells the user their score"
      locate 3,2:?"(under ten).  Speller will say the score after this."
      locate 5,2:style 2:?"Examples";:style 0:?": You scored, your score is, etc."
    end if
    if phr=16 then
      locate 2,2:?"This is what Speller says to tell how many words the user"
      locate 3,2:?"could have scored.  It is only used when the score is less"
      locate 4,2:?"than a perfect one."
      locate 6,2:style 2:?"Examples";:style 0:?": Out of ten, of a possible ten, etc."
    end if
    if phr=17 then
      locate 2,2:?"This is what Speller says just before it exits."
      locate 4,2:style 2:?"Examples";:style 0:?": Bye, see you later, it was nice talking to you, etc."
    end if
  End Sub
  font "topaz.font",8
  Gadget 1,1,"",(13,57)-(528,70),2
  Gadget 2,1,"Next Phrase",(121,71)-(228,83),1
  Gadget 3,0,"Save",(390,71)-(449,83),1
  Gadget 4,1,"Quit",(450,71)-(510,83),1
  Gadget 5,0,"Prev Phrase",(13,71)-(120,83),1
  Gadget 6,1,"Load",(330,71)-(389,83),1
  Gadget 7,1,"Clear All",(250,71)-(329,83),1
  Bevelbox(11,70)-(229,83),2
  Bevelbox(248,70)-(511,83),2
  Bevelbox(5,2)-(525,51),2
  Msg
  Update
  Sv=1
Main:
Scan:
  oktosave=1
  For scn=1 to 17
    if phr$(scn)="" then oktosave=0
  next scn
  Gadget 3,oktosave
  Gadget Wait 0
  Gadg=Gadget(1)
  If Gadg=1 then
    tx$=Cstr(Gadget(2))
    phr$(phr)=tx$
    Speak(tx$)
    sv=0
  End If
  If Gadg=3 then
    file$=filebox$("Select speech filename to save","")
    if file$="" then Main
    Open "I",1,file$
    If eof(1)=0 then
      resp=msgbox("File exists!","Overwrite","Cancel")
      if resp=0 then Close 1:goto Main
    End if
    Close 1
    Open "O",1,file$
    Print #1,Chr$(5)+Chr$(16)+Chr$(67)
    For wrt=1 to 17
      Print #1,phr$(wrt)
    Next wrt
    Close 1
    sv=1
    msgbox "File successfully saved.","Ok"
  End If
  If Gadg=6 then
    if sv=0 then
      resp=msgbox("Current phrases have not been saved!  Really load?","Yes","Cancel")
      if resp=0 then main
    end if
Lode:
    inc=1
    file$=filebox$("Select speech filename to load","")
    if file$="" then Main
    Open "I",1,file$
    If eof(1)=-1 then msgbox "File not found!","Ok":close 1:goto main
    Line Input #1,test$
    if test$<>Chr$(5)+Chr$(16)+Chr$(67) then msgbox "Invalid speech file!","Ok":Close 1:goto main
    For rd=1 to 17
      line input #1,phr$(rd)
      if eof(1) and rd<17 then
        inc=msgbox("This speech file is incomplete! Use it anyway?","Yes","Load Another")
        exit for
      end if
    Next Rd
    Close 1
    If inc=0 then Lode
    If inc=-1 then
      for wiperest=rd+1 to 17
        phr$(wiperest)="Not Found"
      next wiperest
    End If
    sv=1
    phr=1
    gadget 5,0
    gadget 2,1
    update
    msg
    Goto Main
  End If
  If Gadg=4 then Ext
  If Gadg=7 then
    resp=msgbox("Really clear all phrases?","Yes","Cancel")
    if resp=-1 then
      for wipe=1 to 17
        phr$(wipe)=""
      next wipe
      phr=1
      sv=1
      gadget 5,0
      gadget 2,1
      update
      msg
    end if
  End If
  If Gadg=2 then
    ++phr
    Gadget 5,1
    If phr>17 then phr=17
    if phr=17 then Gadget 2,0
    Update
  End If
  If Gadg=5 then
    --phr
    Gadget 2,1
    If Phr<1 then phr=1
    If Phr=1 then Gadget 5,0
    Update
  End If
  If Gadg=2 or Gadg=5 then call Msg
  Goto Main
Ext:
  If sv=0 then
    resp=msgbox("Current phrases have not been saved!  Really Quit?","Yes","Cancel")
    if resp=0 then Main
  End If
  Window Close 1
  End
