/* Make Phrase File entry */

/* Copyright 1992 by Software Industry & General Hardware */
/* All Rights Reserved */

/* Use of this product is at your own risk. */

/* Software Industry & General Hardware is not responsible
   for loss of of data or damage to data or equipment.    */

OPTIONS RESULTS
Extract
Phrase = RESULT
/* if an error occured in obtaining our phrase then return
   to ProWrite(TM) with complaint
*/

If RC ~= 0 Then EXIT RC

/* Extract removes the text, so put the exact phrase back
   into the file where it was
*/

Type Phrase

/* Strip off the trailing spaces on any phrases
*/

Phrase = TRIM( Phrase )

/* Check to see if PhraseFile exists already, if so add to it,
   if not create it.
*/
IF ~EXISTS( "T:PhraseFile" ) THEN DO
   OPEN( PF, "T:PhraseFile", WRITE )
   WRITELN( PF, Phrase );
   CLOSE( PF )
  END
 ELSE DO
  /* Check for duplicates */
  OPEN( PF, "T:PhraseFile", READ)
  DO WHILE ~EOF(PF)
    OldPhrase = READLN( PF )
    IF OldPhrase = Phrase THEN BREAK
  END

  CLOSE( PF )
  IF OldPhrase ~= Phrase THEN DO /* write phrase it is not a duplicate */
    OPEN( PF, "T:PhraseFile", APPEND)

    /* Write the phrase with a newline character */
    WRITELN( PF, Phrase )
    /* shutdown the file and close it */
    CLOSE( PF )
  END
 END
 /* return with success status */
EXIT 0
