βΉοΈ 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 )
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
π What This Example Does:
- getFocus trigger: When a user clicks on a field, the label becomes bold
 - loseFocus trigger: When the user clicks away, the label returns to normal text
 - $stripAttributes: Removes formatting (like bold) from text
 - $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)