Note: This article was created with AI assistance to help developers understand Uniface 10.4 features better.
What is $text? π€
The $text function in Uniface 10.4 is a simple way to get message texts and help texts in your application. Think of it as your message library manager that speaks multiple languages! π
Basic Syntax π»
Using $text is straightforward:
$text(IDString)
Where IDString is the name of your message. Simple, right?
Real World Example π―
Let's say you want to display help text for a field. Here's how you do it:
trigger help
help/noborder $text(HELPTEXT),3,4,7,23
end; help
If you have a naming convention for help messages (like adding _HLP to field names), you can make it even more dynamic:
trigger help ; of field
help $text("%%$fieldname%%%_HLP")
end; help
Smart Language Features π£οΈ
Here's where $text gets really clever! It automatically uses your current language and library settings from $language and $variation. If it can't find your message in the current language, Uniface doesn't give up. It falls back to USA language and USYS library. Pretty smart! π§
Important Things to Know β οΈ
- Return Values: You get the text of your message, or message 8006 if the message doesn't exist
- Where to Use: You can use
$textin all component types - Server Usage: When running on a server, make sure your text messages are in a UAR file
- Check Before Using: Use
$textexistto check if a message exists before calling$text
Working with Variables π§
If you store your message ID in a variable, you need to substitute it properly in a string:
vString = "9004"
help $text("%%vString")
Notice the %% before the variable name? That's important! β¨
Quick Example for Labels π·οΈ
Want to get text for a label? Easy:
vLabelText = $text(%%$fieldname)
Why Use $text? π‘
- Makes your application multilingual ready
- Keeps messages in one place (runtime libraries)
- Easy to maintain and update texts
- Automatic fallback to default language
Pro Tips π
- Create a consistent naming convention for your messages
- Always check message existence with
$textexistbefore accessing it - Document your message IDs for your team
- Test with different languages to ensure fallback works
Conclusion π
The $text function is your friend for managing messages and help texts in Uniface applications. It's simple to use, supports multiple languages automatically, and helps keep your code clean and maintainable. Start using it today and make your application more professional! π
Happy coding! π¨βπ»π©βπ»
Top comments (0)