thinBasic allows you to access the Windows clipboard. You can use this fact to gain access to data placed into the clipboard during editing when a macro is executing.

To get the contents of the clipboard:


clip = ClipBoard_GetText

To change the contents of the clipboard:

ClipBoard_SetText (stringExpression)

Keep in mind that when you copy text into the clipboard, it will normally be stored with a trailing CR/LF pair. SPFLite handles this automatically when you are editing, but if you directly access the clipboard in a thinBasic macro, you are going to see a CR/LF pair for every line in the clipboard - even when you only copied a single word from a single line.

If this an issue, there are few things you can do to deal with this:

    • You can KEYMAP a key or mouse button to (CopyPasteRaw), which copies data to the clipboard without the CR/LF line terminator.
    • You can scan the returned string, and trim off the CR/LF



clip = ClipBoard_GetText

if Right$(clip,2) = $CRLF then

    clip = Remove$(clip, $CRLF)

end if

This example would remove ALL instances of CR/LF, even ones embedded in the middle if the clipboard had more than one line.

If you are going to handle multi-line clipboards, you will probably need more involved macro coding than this, but for simple strings this should be enough to get by.

Created with the Personal Edition of HelpNDoc: Write EPub books for the iPad