CLB. - Clipboard Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Clipboard Commands > Set Clipboard Text >

CLB. - Clipboard Operations

CLB.Trim

Previous Top Next


SPR Script Language

 

CLB.Trim

Trims text in the clipboard from both sides using specified characters.

 

Intention

 

The CLB.Trim command in SPR directly modifies the text in the system clipboard by removing specified characters ($$CHR) from both the left and right sides. This is especially useful for handling Unicode text in the clipboard, which might lose fidelity when converted to ANSI in SPR variables and transferred back. By trimming directly in the clipboard, it preserves the original text format.

 

Imagine it as telling your robot, “Clean up the clipboard text by cutting off these characters from both ends,”—and it trims the text right where it sits, keeping its Unicode intact.

 

Illustration

Suppose the clipboard contains:

" Hello World "

- 🔍 CLB.Trim| (a space) trims spaces from both sides, leaving "Hello World" in the clipboard.
- 🔍 If the clipboard has "***Text***", CLB.Trim|* trims asterisks, leaving "Text".

 

Syntax

 

CLB.Trim|$$CHR

 

Parameter Explanation

 

P1 - $$CHR - (Variable, String)

The characters to trim from both sides of the clipboard text (e.g., $$CHR as " " or "*"). Required. All characters in this string are removed from the left and right edges.

 

Examples

 

'***********************************

' CLB.Trim - Sample 1: Trim Spaces

'***********************************

' Set clipboard with extra spaces

$$VAR= Hello World$sp$ 

CLB.Set|$$VAR

CLB.Trim|$sp$"{, }

' Get trimmed text

CLB.Get Text|$$TXT 

MBX.Trimmed: $$TXT ' Displays "Hello World"

'

'***********************************

' CLB.Trim - Sample 2: Trim Multiple Characters

'***********************************

CLB.Set|***Text***

CLB.Trim|*

CLB.Get|$$TXT

PRT.Trimmed: $$TXT

'

'***********************************

' CLB.Trim - Sample 3: Trim Unicode Text

'***********************************

' Unicode "Hello" in Chinese

' Clipboard contains Emojis or other chines characters for example: 你好 

CLB.Trim| 

CLB.Get Text|$$TXT

' Displays "你好" (preserves Unicode in clipboard)

MBX.Trimmed: $$TXT 

'

 

Remarks

 

- Trims all characters specified in $$CHR from both the left and right sides of the clipboard text.

- Works directly in the clipboard, preserving Unicode text without conversion to ANSI.

- If $$CHR is empty, no trimming occurs.

 

Limitations

 

- Requires text to be present in the clipboard; fails silently if the clipboard is empty or non-text.

- Only trims characters specified in $$CHR; does not trim whitespace by default unless space is included.

- No status code is returned; check results with CLB.Get.

 

See also:

 

CLB.Set Text

CLB.Get Text

CLB.Clip Alll