Platforms to show: All Mac Windows Linux Cross-Platform

Back to DictionaryServiceMBS module.

DictionaryServiceMBS.GetTermRangeInString(text as string, offset as Integer=0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 7.7 ✅ Yes ❌ No ❌ No ✅ Yes All
Determines the range of the longest word or phrase with respect to an offset.

text: Text that contains the word or phrase to look up.
offset: A character offset in the textString parameter.

Return Value

The range that specifies the location, around the specified offset, of the word or phrase, or the value -1. The range is stored in the RangePosition and RangeLength properties and the function returns true. On any error it returns false.

You can use this function to determine the range of text that contains a word or phrase. After you determine the range, you can pass the result to the functions TextDefinition and Show.

To see how this works, follow these steps:
In Mac OS X v10.5 or later, open Text Edit.
Type It is a foggy day in San Francisco, California.
Control-click Francisco (don't select it). Then, choose "Lookup in Dictionary".

Note that the Dictionary window appears with a definition of San Francisco. The function GetTermRangeInString automatically detected the range of the phrase San Francisco, using Francisco as the text string to search for and a character offset in this string. The function expanded the range until it found a possible match.

You can also point the cursor at the word Francisco and, without making a selection or clicking, type Command-Control-D. GetTermRangeInString detects the range.

The function GetTermRangeInString only returns the range. You must call TextDefinition to copy the definition and Show to display the definition in a Dictionary window.

Available in Mac OS X v10.5 and later.

Some examples using this method:

DictionaryServiceMBS.RangeLength as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 7.7 ✅ Yes ❌ No ❌ No ✅ Yes All
The length from the range.

This value set by the GetTermRangeInString function.
(Read and Write computed property)

Some examples using this method:

DictionaryServiceMBS.RangePosition as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 7.7 ✅ Yes ❌ No ❌ No ✅ Yes All
The position from the range.

This value set by the GetTermRangeInString function.
(Read and Write computed property)

Some examples using this method:

DictionaryServiceMBS.Show(text as string, start as Integer = 0, length as Integer = 0, textOriginX as Double = 0, textOriginY as Double = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 7.7 ✅ Yes ❌ No ❌ No ✅ Yes All
Displays dictionary search result in a dictionary window.

text: Text that contains the word or phrase to look up.

start and length:
If you are using this function to show the results associated with text selected by the user, then provide the selection range of the textString parameter. If you are using this function to show the results associated with calling the DCSGetTermRangeInString function, then provide the range returned by that function.

This function opens a window to display the definition of a word or phrase.

Available in Mac OS X v10.5 and later.

DictionaryServiceMBS.TextDefinition(text as string, position as Integer=0, length as Integer=0) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 7.7 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the definition associated with the provided text range.

text: Text that contains the word or phrase to look up.

position and length: A range that specifies the location of the word or phrase in the textString parameter. If text string exactly specifies the word or phrase that you want to look up, you can pass the range of the text string. For example, for the word make, you would pass (0,4) to specify the range.

If the textString parameter contains the word or phrase, but does not specify it exactly, then pass the range returned by the function GetTermRangeInString.

Return Value:
The definition of the word or phrase, as plain text. The returned text does not contain any elements that are marked with a priority attribute whose value is 2.

This function returns the description of the first matching record found in the the active dictionaries. It searches first in the default word definition dictionary which, in the English environment, is the Oxford dictionary.

Available in Mac OS X v10.5 and later.

Some examples using this method:

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...