WPCubed Product Support

Spell check question - Ignoring merge fields

rackerson

I am using WPTools 6.08 with Delphi 6 and Addict 3.5. I have everything installed (I believe) properly - spell check and thesaurus both work fine. However I am having an issue getting the spellcheck to ignore WPTools objects included in the SpellIgnoredForObj property - specifically, merge fields.
The merge fields in my system are actually fields from one of several database tables. I create the merge fields using WPTools' InputMergeField command, passing it a calculated fieldname (consisting of the database name, table name, and column name of the merge variable) and the actual column name for the DisplayText parameter.
For example, for a column named ADDR1 in my Patient table, my InputMergeField call looks something like:
InputMergeField('MRG|DB:Client|TBL😛atient|COL:Addr1', 'ADDR1')
Merging works correctly.
However, when I try to use spellcheck, the display text of my merge variable "ADDR1" is flagged as being misspelled. The SpellIgnoredForObj property of the WPTools editor includes the [wpobjMergeField] option.

What else do i need to do to skip these merge fields?

#1 ♥ 0
10.8k Views 2 users read 5 min
support

Hi,

The Ignore option should disable the curly red underline for the field - that part is controlled by WPTools.

The specllcheck itself happens in the Addict unit.

WPSpell will use this code to skip the fields in future - hopefully You find the correct spot to put it in in Addicts unit.

// Skip hidden text and merge fields
      while (pos < par.CharCount) and (par.IsWordDelimiter(pos) or IsHidden(par, pos)) do
      begin
         obj := par.ObjectRef[pos];
         if obj<>nil then obj := obj.EndTag;
         if (obj<>nil) and
            (par.ObjectRef[pos].ObjType in [wpobjMergeField]) then
         begin
            par := obj.ParentPar;
            pos := obj.ParentPosInPar;
         end;
         inc(pos);
      end;

That should be in function TWPToolsControlParser.MoveNext:Boolean;

#2 ♥ 0
rackerson

Okay, I found the spot to insert this code but I have a couple of questions I hope you can assist with.

First, the body of the TWPToolsControlParser.MoveNext is:

function TWPToolsControlParser.MoveNext: Boolean;
begin
{$IFDEF WPTOOLS5}
  FEdit.HideSelection;
  repeat
    Result := FEdit.CPMoveNext;
    // we use the WPAT_ParFlag property here (requires WPTools V5.18.5 or later)
    // we use the constants  WPAT_ParFlag=127; WFLG_NOPROOF = 4;
  until (not Result) or ((FEdit.ActiveParagraph.AGetDef (127, 0) and 4) = 0);
{$ELSE}
  Result := FEdit.CPMoveNext;
{$ENDIF}

  if FUsingEnd and (FEdit.CPPosition > FEnd) then
  begin
    Result := False;
  end;
end;

I believe I should be able to insert your code following the ENDIF directive. However I just want to make sure I am using the proper values.

  1. You used a variable named "pos" in your WHILE loop. I assume this value is the same as FEdit.CPPosition. Correct?
  2. You use an object named "par" in your code. I assume this is the active paragraph, or FEdit.ActiveParagraph. Correct?
  3. The third portion of your WHILE condition is "IsHidden". I can only find two references to anything named IsHidden is all of the source for WPTools. Both are properties of records, TWPPaintExtraParams and TWPFontCacheInput, not methods. Is this something new?
#4 ♥ 0
support

You need the variables

par : TParagraph;
pos : Integer;
obj : TWPTextObj;

then do a

par := FEdit.ActivateParagraph;
pos := Fedit.ActivePosInPar;

after the CPMoveNext

and then insert my code

and then assign par and pos back ActiveParagraph and ActivePosInPar

#5 ♥ 0
rackerson

thank you for the followup info. I will try this now!

#6 ♥ 0
rackerson

ok, just one more question about you latest post...

your original code snippet contains the following segment on your WHILE loop...

IsHidden(par, pos)

What IS this? I don't have an IsHidden method in any of the WPTools source I purchased.

#7 ♥ 0
rackerson

As a further followup, I tried simply commenting out the IsHidden method (not expecting that to be a good idea) and tested the spell check.
The good news: Addict correctly skipped all of my merge fields!
The bad news: Addict now flags EVERYTHING as being mispelled! It seems that all words on a line within a single data block are read without the spaces and analyzed as if they were a single word. :-(

For example, the title of one of my documents is: Writing MTS and COM+ Components in Delphi. Note there is a single space between each word. When I run the spell check before adding the new code, everything is processed properly. However, with the new code Addict reads this sentence as if it was the single word WritingMTSandCOM+ComponentsinDelphi and flags it as being misspelled.

I assume this is because of my commenting out the unknown IsHidden method. Correct?

#8 ♥ 0
rackerson

Sorry to keep bringing this one up, but could you possibly shed some light on exactly what the IsHidden method you reference is? The only IsHidden I have anywhere in your source (I have the Premium edition) is properties of two records.

#9 ♥ 0
support

Hi,

IsHidden does nothing important. It just checks if a character is marked hidden. It would not separate into words.

I don't have any insight right now why Addict worked before and not after the change since basically I see no difference, only that You skip fields.

Julian

#10 ♥ 0
This category is archived. No new posts are possible.