home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR8 / GCMACRO.ZIP / SS1WORD.S < prev   
Text File  |  1993-05-10  |  4KB  |  83 lines

  1.  
  2. /*****************************************************************************
  3.    Uses ShareSpell to check a single word as defined by current word set. The
  4.      new (or same) word is insert blind inplace of the checked word.  If the
  5.      source word is spelled correctly, ShareSpell simply exits.  Have not
  6.      figured out how to test and put up message "Word spelled correctly".
  7.  
  8.    If the cursor is not on a word, will ask for a word and then ask if the new
  9.      word should be inserted into the file.  If ShareSpell is aborted with F10
  10.      or <cr>, will still ask to insert word, need a test.
  11.  *****************************************************************************/
  12.  
  13. proc Main()
  14.   string  ckWord[20] = "",                  // word to spell check
  15.          newWord[50] = "",                  // spell checked word
  16.           ckFile[12] = "J'K'",              // name of check word file
  17.            macEV[30] = GetEnvStr("SEMAC")   // EV path to SE macros
  18.   integer   spell_id,                       // file for word check
  19.              curr_id = GetBufferID(),       // source buffer
  20.               onWord = FALSE                // true if cursor on word
  21.  
  22.     GotoBufferId(curr_id)                   // point to source buffer
  23.     PushBlock()                             // save any marked blocks
  24.  
  25.     MarkWord()                              // mark word to check
  26.     onWord = iif(isBlockInCurrFile(),TRUE,FALSE) // is word marked ??
  27.  
  28.     spell_id = CreateBuffer(ckFile)         // get buffer to check word
  29.     if spell_id == FALSE                    // if can't do it - bye bye
  30.        Return()
  31.     endif
  32.  
  33.     if onWord                               // HAVE WORD
  34.           CopyBlock()                       // copy the word
  35.     else                                    // DONT HAVE WORD
  36.         Ask("Enter word to check ",ckWord)  // no word, ask for one
  37.         if Length(ckWord) == 0              // ah!, a mistake - get out
  38.             AbandonFile()
  39.             return()
  40.         endif
  41.         InsertText(ckWord)                  // put word in check buffer
  42.         WordLeft()                          // step back onto word
  43.     endif
  44.  
  45.     // This is the same code a mExecMacro().  Can existing code in SE somehow
  46.     //   be called from an external macro ???
  47.     if Length(macEV)                        // is there an EV path
  48.        ExecMacro(macEV+"\SS")
  49.     elseif  FileExists(LoadDir()+"SS")      // if not in environment assume
  50.        ExecMacro(LoadDir()+"SS")            //   SS in same directory as SE
  51.     else
  52.        ExecMacro("SS")                      // hope it's on the path
  53.     endif
  54.  
  55.     ////// test for correctly spelled word
  56.     MarkColumn()                            // begin block
  57.     while CurrChar() >= 0                   //  (maybe more than one word)
  58.       Right()
  59.     endwhile
  60.     Left()                                  // get back on last char
  61.     MarkColumn()                            // end block
  62.     newWord = GetMarkedText()               // get the word
  63.     AbandonFile()                           // close the check buffer
  64.     GotoBufferId(curr_id)                   // back to source buffer
  65.     UpdateDisplay()
  66.  
  67.     if onWORD
  68.         MarkWord()                          // get rid of word and
  69.         DelBlock()                          //   insert new one
  70.         InsertText(newWord,_INSERT_)
  71.     else
  72.         ////// need check to bypass
  73.         if YesNo('Insert "'+newWord+'" at cursor') == 1
  74.           InsertText(newWord,_INSERT_)
  75.         endif
  76.     endif
  77.  
  78.     EraseDiskFile(ckFile)               // get rid of ShareSpell files
  79.     EraseDiskFile(ckFile+".bak")
  80.     PopBlock()                          // put back any previous block
  81. end
  82.  
  83.