DEV Community

Peter + AI
Peter + AI

Posted on

Demystifying Uniface 10.4: Importing Symbol Tables with $ude πŸš€

Disclaimer: This blog post was drafted with the assistance of an AI to help explain technical documentation in a simple and clear way.

Hey everyone! πŸ‘‹ If you've ever worked on a large, mature Uniface application, you've probably asked yourself: "Where on earth is this field or component being used?" Finding all references can feel like searching for a needle in a haystack. But don't worry, Uniface has a powerful feature to help you out: cross-reference data.

In this post, we'll look at a specific ProcScript function that is key to building this data: $ude("import", "symboltable"). Let's break it down!

What Are Symbol Tables Anyway? πŸ€”

Think of symbol tables as an index or a map of your application. When you compile your Uniface components (like forms, services, reports), the compiler can generate symbol table files (.sym). These files contain information about all the objects within that component and where they are used.

By importing these symbol tables into the repository, you can then use Uniface's cross-reference tools to easily answer questions like:

  • Which components use the entity CUSTOMER?
  • In which scripts is the field TOTAL_PRICE modified?
  • Show me every service that calls the GET_USER_DATA operation.

This is incredibly useful for impact analysis before making changes!

The Magic Command: $ude("import", "symboltable") ✨

The core of this process is the $ude function. It's a versatile utility function in Uniface, and we're focusing on its ability to import symbol tables. The data gets loaded into a special repository table called UXCROSS.DICT.

The basic syntax looks like this:


vResult = $ude("import", "symboltable", "ResourceProfile", "", "OptionsList")
Enter fullscreen mode Exit fullscreen mode

Let's look at the main parts.

A Practical Example πŸ’»

The easiest way to learn is with an example. Let's say you want to import the symbol table information for all compiled objects in your library MY_LIB whose names start with CUST_.


variables
  numeric vResult
endvariables

; Import symbol tables for all compiled objects starting with CUST_
vResult = $ude("import", "symboltable", "CUST_*", "", "library=MY_LIB")

if (vResult < 0)
  putmess "Error importing symbol tables: %%$procerror - %%$procerrorcontext"
else
  putmess "Successfully processed %%vResult records."
endif
Enter fullscreen mode Exit fullscreen mode

Let's break down the $ude call:

  • "import", "symboltable": This tells Uniface exactly what we want to do.
  • "CUST_*": This is the ResourceProfile. We're using a wildcard (*) to match all compiled objects starting with "CUST_". This is super handy for batch processing!
  • "": This fourth parameter is not used in this specific case, so we leave it empty.
  • "library=MY_LIB": This is the OptionsList. Since we are importing objects that belong to a library, we need to specify it.

Getting More Specific with Resource Types

Sometimes, you don't want to import everything. You might only want to import symbols for your services or forms. You can do this by adding a ResourceType\ to the second parameter.

For example, to import symbols only for the component ORD\_DETAIL\:


; The resource type is 'component'
vResult = $ude("import", "symboltable;component", "ORD_DETAIL", "", "")
Enter fullscreen mode Exit fullscreen mode

Some common resource types you can use are:

  • component
  • form
  • service
  • report
  • model (for modeled entities)

Checking for Success or Failure βœ…βŒ

How do you know if the import worked? The return value of $ude tells you!

  • A value of 0 or greater (>= 0) means it was successful. The number represents how many records it attempted to process.
  • A negative value (< 0) means an error occurred.

If you get an error, you should always check the built-in ProcScript functions $procerror and $procerrorcontext. They will give you the exact error code and a detailed message, which is essential for debugging.

Conclusion

Using $ude("import", "symboltable") is a fundamental step for enabling Uniface's powerful cross-referencing capabilities. It helps you keep track of your application's structure, making maintenance and development much easier. It might seem like a small utility, but in a large project, it's a real lifesaver!

Happy coding! πŸ’™

Top comments (0)