β οΈ This blog post was created with AI assistance.
π What is $stripattributes?
In Uniface 10.4, the $stripattributes function is your go-to tool when you need to clean up formatted text. It removes character attributes like bold, italic, and underline, as well as frames and rulers from a string.
Think of it as a text cleaner that strips away all the visual formatting, leaving you with plain text. π§Ό
π§ How to Use It
The syntax is simple:
$stripattributes(String)
Where String can be:
- A string literal
- A field name
- A variable
- A function that returns a string
π‘ Practical Example
Let's say you have a field called MYFIELD that contains formatted text. You want to copy this text to an edit box without any formatting:
MYFIELD = "aaabbb"
EDITBOX = $stripattributes(MYFIELD)
; EDITBOX now contains "aaabbb" without formatting
π― When Should You Use It?
Here are some common scenarios where $stripattributes comes in handy:
1οΈβ£ Data Export
When exporting data to CSV or text files, you don't want formatting attributes to mess up your output. Use $stripattributes to ensure clean, plain text.
2οΈβ£ Database Storage
If you need to store text in a database field that doesn't support formatting, strip the attributes first to avoid character encoding issues.
3οΈβ£ Text Processing
When comparing or searching through text, formatting can interfere with your logic. Clean the text first for accurate results.
4οΈβ£ Copy Operations
Moving text between different UI components where one supports formatting and the other doesn't? Strip the attributes to prevent display issues.
β οΈ Important Note
In Uniface 10.4, characters that aren't supported in the target character set are NOT stripped from the string. This is different from Uniface 8, where they were removed. Keep this in mind when working with special characters! π€
π Where Can You Use It?
Good news! The $stripattributes function works in all Uniface component types, so you can use it anywhere in your application. β¨
π Quick Tips
- Always test your output: Make sure the stripped text looks as expected, especially with international characters.
- Combine with other functions: You can use
$stripattributestogether with functions like$trimor$uppercasefor more complex text processing. - Performance: This function is lightweight and fast, so don't worry about using it frequently in your code.
π Related Functions
If you're working with text formatting, you might also want to check out:
-
$bold- Add bold formatting -
$italic- Add italic formatting -
$underline- Add underline formatting
π Final Thoughts
The $stripattributes function is a small but powerful tool in your Uniface toolkit. Whether you're cleaning up user input, preparing data for export, or ensuring consistent text display across different components, this function has you covered. π
Remember: clean data leads to fewer bugs and happier users! π
Top comments (0)