Skip to main content

TrText_GetClipboardAsText (function reference)

By October 1, 2024October 10th, 2024Online Help, Troi Text Plug-in
Troi Text Plug-in > Functions reference > TrText_GetClipboardAsText
Troi Text Plug-in for FileMaker Pro

TrText_GetClipboardAsText

Returns the text contents of the clipboard. Can also return FileMaker script(s) or script steps (fmxmlsnippet XML) as text.

SyntaxFunction badge

TrText_GetClipboardAsText( switches )

Parameters

switches not used, reserved for future use. Leave blank or put "-Unused"

Returned Result

Data type returned

Text

Result

Returns the text contents of the clipboard. Can also return a fmxmlsnippet as text: FileMaker script(s) or script steps that you copy from the Script Workspace.

Originated in

Troi Text Plug-in 6.0

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

When multiple variants of text are on the clipboard, the plug-in will try to return the best variant, for example it will return UTF-8 text and not the ASCII text.

This function can also return fmxmlsnippets that are copied to the clipboard.
A fmxmlsnippet is XML formatted data that is put on the clipboard when you copy scripts or other structure elements of a FileMaker database.
You can get these types of fmxmlsnippets as text:
– Script(s) copied from Script Workspace
– Script step(s) copied from Script Workspace
– Field(s) copied from Manage Database
– Table(s) copied from Manage Database
– Value List(s) copied from Manage Value Lists
– Layout object(s) copied from a layout

Example

Set Variable [ $Result ; TrText_GetClipboardAsText ( "-unused" ) ]

The result is the text of the clipboard, for example “Hello: This is some text”.

Example 2

Create a script “Get Script snippet from clipboard”:

Set Variable [$Result, TrText_GetClipboardAsText( $Switches )]
If [ Left($Result ;2)  <>  "$$" ]
  # No error, now also store in a field:
  Set Field [fmSnippet, $Result]
End If

With this script you can now quickly copy scripts or script steps:
– Open Script Workspace of the FileMaker file you want to copy a script(step) from.
– Select one or more scripts, or in a script select one or more script steps.
– Copy the selection to the clipboard (with Edit –> Copy).
– Now run script “Get Script snippet from clipboard” to get the fmxmlsnippet as text.

A (simplified) result can be for example:

<fmxmlsnippet type="FMObjectList">
  <Script id="1" name="Get Text from clipboard">
    <Step  name="# (comment)">
      <Text>A sample comment</Text>
    </Step>
    <Step name="Set Variable">
      <Value>
        <Calculation>
<![CDATA[  TrText_GetClipboardAsText("")  ]]>
        </Calculation>
      </Value>
      <Name>$$Result</Name>
    </Step>
    <Step name="Exit Script">
    </Step>
  </Script>
</fmxmlsnippet>

Related functionFunction badge

TrText_XML

Related topics

Troi Text Plug-in online help (overview)


Online Help Page for Troi Text Plug-in for 17 to 2024 –> TrText_GetClipboardAsText (textp4300) 2024-1010 14:42:55