DEV Community

Peter + AI
Peter + AI

Posted on

Understanding Uniface's Deprecated fieldsyntax Statement πŸ“š

This article is based on Uniface Documentation 10.4 and was created with AI assistance.

If you're working with legacy Uniface applications, you might encounter the fieldsyntax statement. While this feature is now deprecated, understanding it can be crucial for maintaining older codebases. Let's dive into what it does and why it's being phased out! πŸ”§

What is fieldsyntax? πŸ€”

The fieldsyntax statement was used to dynamically set syntax attributes for fields in Uniface applications. It allowed developers to control field behavior such as editability, visibility, and prompting during runtime.

Basic Syntax:

fieldsyntax Field, AttributeList
Enter fullscreen mode Exit fullscreen mode

Example Usage:

fieldsyntax FIELD1, "NED,NPR"
Enter fullscreen mode Exit fullscreen mode

Key Attributes πŸ—οΈ

Here are the main field syntax attributes you could use:

  • NDI - Do not display the field content
  • NED - Do not allow editing
  • NPR - Do not prompt (not available in web environment)
  • HID - Hide field completely (NDI + NED + NPR)
  • DIM - Dim the field (no editing/prompting)
  • YDI - Display field
  • YED - Allow editing
  • YPR - Allow prompting

Real-World Example πŸ’‘

Here's a practical example showing conditional field behavior:

if (DISCOUNT_1 != 0)
    fieldsyntax DISCOUNT_2, "NED,NPR"
endif
Enter fullscreen mode Exit fullscreen mode

This code makes the DISCOUNT_2 field non-editable and non-promptable when DISCOUNT_1 has a non-zero value.

Why is it Deprecated? ⚠️

The fieldsyntax statement has been superseded by the $fieldsyntax function, which offers:

  • Better compatibility across all component types
  • More consistent behavior
  • Enhanced functionality
  • Future-proof design

Migration Strategy πŸš€

If you're maintaining legacy Uniface code:

  1. Audit your codebase - Find all instances of fieldsyntax
  2. Plan migration - Replace with $fieldsyntax function calls
  3. Test thoroughly - Ensure behavior remains consistent
  4. Document changes - Help future developers understand the updates

Important Notes πŸ“

  • The ^CLEAR and ^RETRIEVE structure editor functions reset field syntax
  • Some attributes like HID are not valid in character mode
  • NPR is not available in web environments
  • Positive attributes (YDI, YED, YPR) can only be set programmatically

Conclusion 🎯

While fieldsyntax served its purpose in older Uniface versions, modern development should use the $fieldsyntax function. Understanding both helps maintain legacy systems while planning for future upgrades.

Remember: deprecated doesn't mean broken, but it does mean you should plan for migration! πŸ”„


Have you worked with Uniface's field syntax features? Share your experiences in the comments below! πŸ’¬

Top comments (0)