Most of the application's features can be scripted using Visual Basic (VB), Visual Basic for Applications (VBA), and other COM-aware languages (including C++). This makes Felix a flexible and powerful tool. You can build your own custom scripts to automatically perform various tasks, pre-process documents, and more.
In fact, the various interfaces for Microsoft Word, PowerPoint, and Excel that come with this application, as well as the Tag Assist translator's HTML editor, take advantage of this very feature to perform their magic. You can customize these scripts to your own purposes, or write new ones. You can also write VB or other applications that take advantage of these features.
| Name | Type | Read | Write | Description |
|---|---|---|---|---|
Visible |
Boolean |
|
|
Show/hide the Memory window, and detect whether it is visible. |
NumGlossMatches |
Integer |
|
|
Get the number of matches in the Main glossary. |
NumMatches |
Long |
|
|
Get the number of matches in the memory. |
Query |
String |
|
|
Get or set the current query. Setting the query causes the Memory window to search for matches in the current memory, and the Glossary windows to look for matches in their glossaries. |
Score |
Double |
|
|
Get the score of the currently displayed match. |
Trans |
String |
|
|
Get or set the translation for the current query. Setting the translation creates a new memory entry, with the query as the source and the translation as the translation. |
App2 |
Object |
|
|
Retrieve the App2 interface, with several advanced features. See The App2 Interface for details. |
| Method Name | Parameters | Return Value | Action |
|---|---|---|---|
AddGlossaryEntry |
String Source,String Translation,String Context |
None | Add an entry to the glossary. The source is the current query in the Memory window. |
AddMemoryEntry |
String Source,String Translation,String Context |
None | Add an entry to the memory. |
ClearGlossaries |
None | None | Clear the Main Glossary window memory. |
ClearMemories |
None | None | Clear the Memory window memory. |
Concordance |
String Query |
None | Search the memory for concordances. |
DeleteMemEntry |
None | None | Delete the currently displayed translation. |
GlossMatch |
Integer Index |
String | Get the glossary entry at position Index from the Main glossary. |
NextTrans |
None | None | Show the next translation match. |
PrevTrans |
None | None | Show the previous translation match. |
Quit |
None | None | Quit Felix. |
Save |
None | None | Save the memory and Main glossary. |
TransConcordance |
String Query |
None | Get translation concordance for Query. |
The App2 object provides advanced features.
IdId, correcting the
source and translation as supplied if necessary.This represents a TM or glossary match in Felix. It has the following members.
This represents a Felix TM or glossary record. It has the following members.
Add some memory and glossary entries
' Create the Felix object
Dim felix As Object
Set felix = CreateObject("Felix.App")
' Make it visible
felix.Visible = True
' source, translation, context
felix.AddMemoryEntry "white", "blanco", "from VBA"
felix.AddMemoryEntry "black", "negro", "from VBA"
felix.AddGlossaryEntry "uno", "one", "VBA gloss entry"
felix.AddGlossaryEntry "dos", "two", "VBA gloss entry"
felix.AddGlossaryEntry "tres", "three", "VBA gloss entry"
Clear the glossary and memory
' You could also add the type library to the
' references and declare:
' Dim felix As New FelixLib.App
Dim felix As Object
Set felix = CreateObject("Felix.App")
felix.Visible = True
felix.ClearGlossaries
felix.ClearMemories
Set a translation entry
Dim felix As Object
Set felix = CreateObject("Felix.App")
felix.Visible = True
felix.Query = "Can I automate my TM tool?"
felix.Trans = "Yes, if it's Felix!"
Replace all glossary matches in a Word document with their translations
Sub SubstituteGlossMatches()
' Replace all the Felix glossary matches in the document
' with their translations
' Create the Felix object
Set felix = CreateObject("Felix.App")
' Get the find object...
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Wrap = wdFindStop
' Go through each paragraph
For Each para In ActiveDocument.Paragraphs
' Look up its text
para.Range.Select
felix.Query = para.Range.Text
' Loop through each of the glossary matches
For Each match In felix.app2.CurrentGlossMatches
' Set the source and replacement text
' Use the "Plain" variants to get the text without HTML tags
.Text = match.record.PlainSource
.Replacement.Text = match.record.PlainTrans
' Do the replacement
.Execute Replace:=wdReplaceAll
Next match
Next para
End With
End Sub
Set the query and translation
#include <string> // for wstring
// put this in your path or use the absolute path
#import "Felix.tlb" no_auto_exclude
// Note: obviously, these functions could live in a C++ object,
// which would eliminate the need to call
// CoCreateInstance every time.
// This is the approach that TagAssist uses. However, the sample
// has been condensed into two functions for brevity.
// set the current query
inline void set_query( const std::wstring &query )
{
CComPtr< FelixLib::IApp > felix ;
// error handling omitted for brevity
felix.CoCreateInstance( L"Felix.App",
NULL,
CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER ) ;
// make it visible
felix->Visible = VARIANT_TRUE ;
// put the query
// Felix will respond by showing a
// list of any matches
CComBSTR bQuery( query.c_str() );
felix->Query = bQuery ;
}
// set the translation for the current query
inline void set_trans( const std::wstring &trans )
{
CComPtr< FelixLib::IApp > felix ;
// error handling omitted for brevity
felix.CoCreateInstance( L"Felix.App",
NULL,
CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER ) ;
// make it visible
felix->Visible = VARIANT_TRUE ;
// put the translation
// If there is a current query, this will
// create a new entry, with the query as the
// source and the trans as the translation.
CComBSTR bTrans( trans.c_str() ) ;
felix->Trans = bTrans ;
}