DEV Community

Peter + AI
Peter + AI

Posted on

πŸ“ Understanding Uniface $bold Function: Simple Text Styling in Forms

ℹ️ This blog post was created with AI assistance to help explain Uniface development concepts clearly.

🎯 What is the $bold Function?

The $bold function in Uniface 10.4 is a simple but powerful tool that applies bold character styling to text strings. Think of it like making text bold in a word processor, but specifically for Uniface form components.

πŸ”§ How Does It Work?

The function has a straightforward syntax:

$bold ( String )
Enter fullscreen mode Exit fullscreen mode

Where:

  • String: The text you want to make bold
  • Return Value: The same text with bold formatting applied

⚠️ Important Things to Know

  • 🏠 Form Components Only: This function only works in Form components, not other types of Uniface components
  • πŸ‘οΈ Visual Display: The bold effect is only visible in displayed unifields (user interface fields)
  • 🎨 Character Attribute: It applies a character attribute, which means it affects how the text looks, not the text content itself

πŸ“– Key Terms Explained

  • Unifield: A field in a Uniface form that displays data to users
  • Character Attribute: Formatting that changes how text appears (like bold, italic, underline)
  • ProcScript: The programming language used in Uniface for application logic
  • Trigger: Code that runs when specific events happen (like clicking a field)

πŸ’‘ Practical Example

Here's a real-world example that makes field labels bold when users click on them:

trigger loseFocus 
    putItem/id $labelProperties($fieldname), "text", 
    $stripAttributes($valuePart($labelProperties($fieldname)))
end

trigger getFocus
    putItem/id $labelProperties($fieldname), "text", 
    $bold($valuePart($labelProperties($fieldname)))
end
Enter fullscreen mode Exit fullscreen mode

πŸ” What This Example Does:

  1. getFocus trigger: When a user clicks on a field, the label becomes bold
  2. loseFocus trigger: When the user clicks away, the label returns to normal text
  3. $stripAttributes: Removes formatting (like bold) from text
  4. $labelProperties: Gets or sets properties of field labels

🎯 When to Use $bold

  • πŸ–±οΈ Interactive Forms: Highlight active fields or important information
  • ⚠️ Error Messages: Make warning text stand out
  • πŸ“‹ Dynamic Labels: Change label appearance based on user actions
  • 🎨 Visual Feedback: Provide immediate visual response to user interactions

πŸ”— Related Functions

The $bold function works well with other text formatting functions:

  • $stripAttributes: Removes all formatting from text
  • $italic: Applies italic formatting
  • $underline: Applies underline formatting

βœ… Best Practices

  • 🎯 Use bold sparingly to maintain visual hierarchy
  • πŸ”„ Always provide a way to remove bold formatting when it's no longer needed
  • πŸ“± Test bold text appearance across different screen sizes and resolutions
  • β™Ώ Consider accessibility - ensure bold text maintains good contrast

πŸŽ‰ Conclusion

The $bold function is a simple yet effective tool for enhancing user interfaces in Uniface applications. By understanding when and how to use it, you can create more engaging and user-friendly forms that provide clear visual feedback. Remember to use it thoughtfully and always test your formatting in the actual application environment! πŸš€


πŸ’‘ _Have you used the $bold function in your Uniface projects? Share your experiences and tips in the comments below!_face $bold Function: Simple Text Styling in Forms

Top comments (0)