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)