DEV Community

Peter + AI
Peter + AI

Posted on

πŸš€ Understanding Uniface 10.4: The stripattributes Command Made Simple

πŸ“ This blog post was created with AI assistance to help developers understand Uniface 10.4 better.

Hey there, developers! πŸ‘‹ Today we're diving into one of Uniface 10.4's handy utility commands: stripattributes. If you're working with text formatting in Uniface applications, this little gem can be a real lifesaver! πŸ’Ž

πŸ€” What is stripattributes?

The stripattributes command is like a text cleaner 🧹. It takes formatted text (with things like bold, italic, and underlined characters) and removes all that formatting, giving you clean, plain text.

Technical Definition: stripattributes removes character attributes (bold, italic, underline), frames, and rulers from a source and puts the clean result in a target location.

πŸ“ Basic Syntax

The syntax is super simple:

stripattributes Source, Target 
Enter fullscreen mode Exit fullscreen mode

Where:

  • Source: The original text with formatting (can be a field, variable, or function)
  • Target: Where you want the clean text to go

🎯 Practical Example

Let's say you have a field called MYFIELD containing formatted text, and you want to display it cleanly in an EDITBOX:

MYFIELD = "aaabbb" ; This might contain bold/italic formatting stripattributes MYFIELD, EDITBOX ; EDITBOX now contains clean "aaabbb" 
Enter fullscreen mode Exit fullscreen mode

After running this command, EDITBOX will contain the same text but without any formatting! ✨

πŸ“Š Understanding Return Values

The command tells you what it cleaned up through the $status variable:

  • 0: Nothing was stripped (text was already clean) 😌
  • 1: Character attributes were removed (bold, italic, underline) 🎨
  • 4: Frames were stripped πŸ–ΌοΈ
  • 8: Rulers were removed πŸ“

Pro Tip: These values can be combined! If $status returns 5 (1+4), it means both attributes and frames were stripped. πŸ”§

⚑ When to Use stripattributes

This command is perfect when you need to:

  • Clean up user input before saving to databases πŸ’Ύ
  • Prepare formatted text for plain text displays πŸ“Ί
  • Export data to systems that don't support formatting πŸ“€
  • Create consistent, clean text for reports πŸ“‹

🎨 Key Terms Explained

  • Character Attributes: Text formatting like bold, italic, and underline
  • Frames: Visual borders or containers around text elements
  • Rulers: Measurement guides used in text layout
  • ProcScript: Uniface's programming language for application logic

⚠️ Important Notes

Remember that unknown characters in the target character set won't be stripped - this is different from older Uniface versions that would remove them completely. This helps preserve international characters! 🌍

The stripattributes command works in all Uniface component types, making it super versatile for your applications. πŸ› οΈ

🎯 Conclusion

The stripattributes command might seem simple, but it's incredibly useful for maintaining clean, consistent text in your Uniface applications. Whether you're processing user input or preparing data for export, this little command can save you lots of headaches! πŸ’ͺ

Happy coding, and may your text always be clean! βœ¨πŸš€

Top comments (0)