Smart text in a text frame needs to be able to refer to the current layout window, the current page that the text frame is on, and the text frame's current index into the collection of frames on the current page in order to use various MapBasic functions. This function provides this information that is valid only within a piece of Smart Text.
SyntaxCurContext(context_attribute)
Return Value
Integer
DescriptionReturns information related to the current Layout text frame. Depending on the attribute passed, returns the current Layout window identifier, the current page that the text frame is on, or the text frame's current index into the collection of frames on the current page. This function is valid only within a Smart Text expression in a text frame.
Currently supports 3 attributes as arguments:
Frame Type | ID | Frame Description |
---|---|---|
CONTEXT_WINDOWID | 1 | returns the WINDOW id of the Layout with the text frame containing the Smart Text. |
CONTEXT_PAGENUMBER | 2 | returns the page number (1-based) of the text frame containing the Smart Text. |
CONTEXT_FRAMENUMBER | 3 | returns the frame number (1-based) of the text frame containing the Smart Text. |
CONTEXT_MAPWINDOWID | 4 | returns the map window currently being drawn. |
Example SmartText strings using CurContext
- Displays "Page x of y"
Page $mb{LayoutInfo(CurContext(1), 12} of $mb{LayoutInfo(CurContext(1), 11}
After the smart text, which is on page 1 of a 2 page Layout, is evaluated, the following displays:
Page 1 of 2
- Displays Name property of text frame
$mb{LayoutItemInfo(CurContext(1), CurContext(3), 14}
If you set the text frame's Name property to Main Title, when Smart text is evaluated, the following displays:
Main Title
CurContext may only be used within a Smart Text expression in a Layout Text frame.