 * This program is a spelling drill and definition drill routine to
 * help kids learn their spelling and vocabulary lessons.  It could be
 * adapted for other uses that require memorization of certain data such as
 * state capitols, etc. It has been released into the public domain by its
 * author, John Krahmer, and may be modified as desired by users.  The release
 * date of this version is September 27, 1986.  If subsequent modifications
 * are released by others, it would be highly desirable to revise the 
 * accompanying history file named KIDSPELL.HIS to document changes.  The
 * KIDSPELL.DOC file may also need revision to reflect any modifications.
 * This program (named KIDSPELL.SRC) is heavily documented to permit easy
 * modification.  It will run "as is" using dBase II ver. 2.43 by loading
 * dBase II and typing "Do Kidspell.src" at the dot prompt.  I don't know if
 * it will run under dBase III or in compiled versions.  The file named 
 * KIDSPELL.CMD in this library is a compressed version using DBSQUASH.COM
 * that deletes comments and shortens command lines.  That version will run
 * noticeably faster.  The .SRC extension was added to this file to denote
 * the source code version and distinguish it from the .CMD version.
 *******************************************
 * this section is the standard dbase opening routine
 CLEAR
 SET TALK OFF
 ERASE
 *******************************************
 * this section sets the memory variables
 STORE 0 TO COUNT
 STORE T TO TRUE
 STORE 0 TO HIT
 *******************************************
 * the data base in use is identified in the next line.  change as needed.
 USE KIDWORDS
 *******************************************
 * the next few lines set parameters.  because the program uses the delete
 * function internally to permit recycling for words that are misspelled,
 * that function is initially set to an off status
 SET DELETE OFF
 GO BOTTOM
 STORE #+1 TO MRECORD
 STORE STR(MRECORD,5) TO TEMPREC
 STORE TEMPREC TO MRECORD
 GO TOP
 ? "WHERE WOULD YOU LIKE TO START?  PLEASE ENTER ANY NUMBER LESS THAN: ",MRECORD,"."
 ?
 ? "BE SURE TO USE ONLY CAPITAL LETTERS IN YOUR ANSWERS."
 ?
 ACCEPT "NUMBER? " TO STARTNUM
 ERASE
 * an error trap could go in here to catch any number greater than the
 * number of the last record.  this hasn't been a problem, but add one if
 * needed
 ********************************************
 * this is the beginning of the actual processing
 GOTO &STARTNUM
 DO WHILE TRUE
    DO WHILE .NOT. EOF
       RECALL
       STORE TRIM(!(WORD)) TO MWORD1
       @ 5,0 SAY "HERE IS THE DEFINITION.  PLEASE ENTER THE WORD."
       ?
       IF DEFINE1>" "
          ? TRIM(DEFINE1)
       ENDIF
       IF DEFINE2>" "
          ? TRIM(DEFINE2)
       ENDIF
       ?
       ACCEPT "WORD? " TO MWORD
       *****************************************
 * this section calculates the number of letters that are correctly
 * placed in the word entered at the console and stores the result in
 * the memory variable named "hit."
       STORE 0 TO HIT
       STORE LEN(TRIM(MWORD)) TO X
       DO WHILE X>0
          IF @($(MWORD,X,1),MWORD1)>0
             STORE HIT+1 TO HIT
          ENDIF
          STORE X-1 TO X
       ENDDO
       ************************************************
 * this section uses "do case" statements to select the proper response.
       DO CASE
 * if the user can't determine the word or can't spell it correctly, the
 * word can be requested by entering a question mark or the letter "h" for
 * help
          CASE MWORD="?" .OR. (!(MWORD)="H".AND.LEN(MWORD)=1)
          ERASE
          @ 5,0 SAY "I'LL BE GLAD TO HELP."
          ?
          ? "THE DEFINITION WAS:"
          ?
          ? DEFINE1
          ? DEFINE2
          ?
          ? "THE WORD WAS: ",MWORD1
          @ 24,0 SAY "PRESS ANY KEY TO CONTINUE."
          SET CONSOLE OFF
          WAIT
          SET CONSOLE ON
          ERASE
          STORE 0 TO COUNT
          SKIP
          LOOP
 * if the word is spelled exactly right, this case statement operates.
          CASE MWORD=MWORD1
          ERASE
          @ 5,0 SAY "EXACTLY RIGHT!  THE WORD WAS: "+MWORD1
          DO WHILE COUNT <35
             STORE COUNT+1 TO COUNT
          ENDDO
          RELEASE X
          RELEASE HIT
          STORE 0 TO COUNT
          DELETE
          ERASE
          SKIP
          LOOP
          **************************************
 * if the word is almost, but not quite, correct, this case statement will
 * operate.  if desired, the formula can be varied to require a spelling that
 * is more nearly correct.  at present it is set for an 80% ratio.  by
 * increasing the "hit>.8" figure, greater precision can be required, but
 * this has proven to be about right.  the other part of the formula requires
 * that the total word length be within the stated values.  they also can be
 * varied.  a value of 1.0 for all values in the formula would require exact
 * spelling.
          CASE LEN(MWORD)>=(LEN(MWORD1)*.7) .AND. LEN(MWORD)<=(LEN(MWORD1)*1.4) .AND. ;
          HIT>.8*LEN(TRIM(MWORD1))
          ERASE
          RELEASE X
          RELEASE HIT
          @ 5,0 SAY "YOU WERE CLOSE ENOUGH.  THE WORD WAS: "+MWORD1
          @ 7,0 SAY "YOUR WORD (PERHAPS MISSPELLED) WAS:   "+MWORD
          ?
          ? "PLEASE NOTE ANY ERRORS AND PRESS ANY KEY TO CONTINUE"
          SET CONSOLE OFF
          WAIT
          SET CONSOLE ON
          STORE 0 TO COUNT
          DELETE
          ERASE
          SKIP
          LOOP
          *************************************************
 * if the word is misspelled, this section will operate.  you might want
 * to increase the time delay for the screen message by raising the value of
 * count from 35 to a higher number, depending upon the reading speed and
 * age of the child. if desired, a wait routine for a keypressed could be
 * used instead.  such a routine is used in the last 9 lines of the immediately
 * preceding section.
          OTHERWISE
          ERASE
          @ 5,0 SAY "I'M SORRY.  THAT IS INCORRECT.  TRY AGAIN!"
          STORE 0 TO COUNT
          DO WHILE COUNT <35
             STORE COUNT+1 TO COUNT
          ENDDO
          STORE 0 TO COUNT
          ERASE
          ? "YOU TRIED: "+MWORD
          LOOP
       ENDCASE
    ENDDO
 * the "do while .not. eof" loop is closed at this point and lets the user
 * choose to repeat misspelled words or to end the program.
    ERASE
    @ 5,0 SAY "THAT COMPLETES THE ENTIRE WORD LIST."
    @ 7,0 SAY  "VERY GOOD!"
    @ 12,0 SAY "WOULD YOU LIKE TO RETRY THE WORDS THAT YOU MISSED?"
    ?
    ? "(Y OR N)?"
    SET CONSOLE OFF
    WAIT TO RETRY
    SET CONSOLE ON
    IF RETRY ='Y'
       ERASE
       GO TOP
 * this is the way in which the delete function is used to allow
 * retries of the program.
       SET DELETE ON
    ENDIF
    IF RETRY = 'N'
       STORE F TO TRUE
       SET DELETE OFF
    ENDIF
 * the next line closes the "do while true" loop and terminates the
 * program.
 ENDDO
 CLEAR
 ERASE
 RETURN

    ENDIF
 * the next line closes the "do while true" loop and terminates the
 * 