Writing, done correctly

With CtxDocEdit, conzept 16 provides developers with an object that can be used to implement professional word processing. In addition to functions such as processing different file and image formats or header and footer management, a spell checker is also part of a convenient word processing package.

In the current version of conzept 16, users have the option of activating a spell checker for German and English.


Starting with the upcoming version 5.7.08, conzept 16 will offer the option of expanding the dictionaries with user-defined dictionaries. In this article, I would like to show you how this will work in practice.
Creating a custom dictionary

The dictionary forms the basis for the spell checker. When spell checking is active, the words in the text document are compared with the dictionary and incorrect or unknown terms are underlined with a red zigzag line.

In order for the DocEdit object or the underlying spell checker to process the self-created dictionary, it must be in the so-called Tlx format (Text Lexicon). This is a line-based text file. Each term is on a separate line, followed by a tab and a key. The key indicates how the term is to be interpreted.

Adding a custom dictionary

In order for the text to be checked against the custom dictionary, it must be added to the DocEdit object. The addition is done using the new function WinDocUserDictAddName(). It should be noted that this function can also be used to load several dictionaries at the same time. The Spell Checker always takes into account all dictionaries added to the DocEdit object. The function WinDocUserDictRemoveName() is available for unloading individual dictionaries.

Adding words during text entry

Custom dictionaries are also suitable for expanding German or English dictionaries. Since these dictionaries contain the most frequently used words, proper names, abbreviations, or technical terms are usually not recognized and are marked as errors.

We need two functions to implement this. One function identifies the incorrect term, and the other function writes this term to the user-defined dictionary.

Identifying an incorrect word

sub GetMisspelledWord() : alpha
{
  // Use the position of the word as the starting point for selection
  gCtxDocEdit->cpiSelStart  # gCtxDocEdit->cpiMisspelledWordStart(gIdx)
  // Set the length of the selection to the length of the word
  gCtxDocEdit->cpiSelLength # gCtxDocEdit->cpiMisspelledWordLength(gIdx)
  // Determine selected word
  return (gCtxDocEdit->CpaSelText);
}

The cpiMisspelledWords property can be used to determine whether there are any terms in a text document that need to be corrected. The property returns the number of incorrect terms. Incorrectly spelled or unknown terms are numbered consecutively by the DocEdit object from the beginning to the end of the text.

The above function identifies an incorrect term and highlights it in the text.
The property cpaSeltext returns the selected term as a string. The number of the word is passed to properties cpiMisspelledWordStart and cpiMisspelledWordLength as an argument.

If the user decides to add this word to the user-defined dictionary, the following function is applied.

Adding a word to the dictionary

Sub WriteDictionary(aWord : alpha(84))
{
  // Set pointer to the beginning of the file
  gFile->FsiSeek(0);
  // Import dictionary into memory object
  gFile->FsiReadMem(gMem,1,gFile->FsiSize());

  // If term does not exist
  if (gMem->MemFindStr(1,gMem->SpLen,aWord,_StrFindToken) = 0)
  {
    // Extend term to include tab, key, and line break
    aWord # aWord + mTab + 'i' + mCRLF;
    // Set pointer to end of file
    gFile->FsiSeek(gFile->FsiSize());
    // Write file
    gFile->FsiWrite(aWord);
  }
  // Remove dictionary
  gCtxDocEdit->WinDocUserDictRemoveName(mPath + '\MyDic.tlx');
  // Add dictionary
  gCtxDocEdit->WinDocUserDictAddName(mPath + '\MyDic.tlx');
}

After writing the file, the dictionary must be added again so that the spell checker accepts the word as correct.

DocEdit with spell checker

Klicken Sie hier, um die Nutzungsbedingungen für unseren Blog zu lesen.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

Requests, questions or feedback are welcome:

Terms of use of the comment function in the blog

1. General information

Vectorsoft AG (‘Provider’) provides a public blog for Internet users (‘Users’) on the vectorsoft.de website. The public blog is intended for the exchange of information and ideas. Users who participate with contributions and comments undertake to comply with the blog terms of use and are responsible for the accuracy, appropriateness and freedom from legal infringements of their contributions. By using the comment function in our blog, you accept these terms of use.

2. Netiquette

We ask you to refrain from personal attacks and provocations based on other opinions. Please argue objectively and maintain a constructive discussion culture. Your comment should always be related to the topic in question in order to avoid digressions into other topics. Posting the same comment or several similar comments more than once is not permitted.

3. Prohibition of illegal content

By submitting your comment, you confirm that you are not violating any copyrights or other rights of third parties. Inciting, racist statements, instructions for criminal offences and their glorification, depictions of violence, pornographic content and statements that violate personal rights are prohibited.

4. No advertising

The use of the comment function is not permitted for commercial or party-political purposes. Advertising contributions of any kind will be deleted immediately.

5. Details of the name

When entering your name, pay attention to the principles mentioned above.

6. Source references

If you intend to publish quotes or contributions from third parties, please indicate the respective sources and explain how they relate to the blog post.

7. Violation of the terms of use

Posts that violate this policy will be deleted immediately. If you notice any violations yourself, please send us the link to the comment in question by e-mail to . We expressly point out that we will exclude individual users in the event of repeated or serious violations of these terms of use.

As of: Sept. 2024

Get your Trial Version now!

Test yeet free of charge

IHRE EVALUIERUNGSLIZENZ - JETZT ANFORDERN!

TESTEN SIE DIE CONZEPT 16 VOLLVERSION - UNVERBINDLICH und KOSTENFREI

Subscribe to our newsletter

[cleverreach_signup]
WordPress Cookie Notice by Real Cookie Banner