🚨 Uniface's Deprecated `length` Statement: What You Need to Know
Peter + AI

Peter + AI @petercode

Joined:
Jul 12, 2025

🚨 Uniface's Deprecated `length` Statement: What You Need to Know

Publish Date: Jul 18
0 0

Hey Uniface developers! 👋 If you're still using the length statement in your Uniface applications, it's time for an update. With AI assistance helping me dive deep into this topic, let me walk you through why this statement is deprecated and what you should use instead.

📋 What is the length Statement?

The length statement in Uniface was used to return the number of characters in a specified string. It was a handy tool for string manipulation and validation tasks.

Basic Syntax:

length String
Enter fullscreen mode Exit fullscreen mode

Example Usage:

vString = "test string"
length vString
vLength = $result
OUTPUT = vLength
Enter fullscreen mode Exit fullscreen mode

⚠️ Why is it Deprecated?

According to the Uniface 10.4 documentation, the length statement has been superseded by the $length function, which offers better functionality across all component types.

🔄 Migration Path: From length to $length

The transition is straightforward. Instead of using the statement format, you now use the function format:

Old (Deprecated) Way:

length vString
vLength = $result
Enter fullscreen mode Exit fullscreen mode

New (Recommended) Way:

vLength = $length(vString)
Enter fullscreen mode Exit fullscreen mode

💡 Key Features and Behavior

  • Return Values: Sets $result to the number of characters in the string
  • Status: $status remains unaffected
  • Component Support: Allowed in all component types
  • Special Characters: Ignores frame marker, ruler, and character attribute characters

🎯 Practical Example: Finding String Offsets

Here's a real-world example from the documentation showing how the length statement was used to find the offset to the last two characters in a string:

; Field INVNUM contains: 90021387SH
; (Date: 13-Feb-1990, Number: 87, Initials: SH)

length INVNUM
$1=$result-1
$2=INVNUM[$1]
selectdb (sum(AMOUNT)) %/
 from "INVOICES" %/
 u_where (SALESCODE = $2) %/
 to SALESREPORT.DUMMY
Enter fullscreen mode Exit fullscreen mode

This example extracts the last two characters (salesman's initials) to use in a database query.

🚀 Best Practices Moving Forward

  1. Update existing code: Replace length statements with $length functions
  2. Code reviews: Watch for deprecated length usage in new code
  3. Testing: Ensure functionality remains consistent after migration
  4. Documentation: Update your internal documentation to reflect the change

🔚 Conclusion

While the length statement served us well, it's time to embrace the more versatile $length function. This change aligns with Uniface's evolution toward more consistent and powerful string manipulation capabilities.

Remember: deprecated doesn't mean broken, but it does mean you should plan for migration in your development roadmap! 📅

This article is based on Uniface Documentation 10.4

Comments 0 total

    Add comment