For Uniface developers managing extensive and intricate applications, a common challenge is tracing the usage of specific fields, components, or operations. Understanding where elements are referenced is crucial for effective maintenance, impact analysis, and successful development. Fortunately, Uniface provides a robust solution through its cross-reference data capabilities, central to which are symbol tables.
Understanding Uniface Symbol Tables
At its core, a symbol table acts as a comprehensive index of your Uniface application. When Uniface components – such as forms, services, or reports – are compiled, the compiler has the option to generate .sym files. These files are repositories of metadata, detailing all the objects within a component and their interdependencies.
By integrating these symbol tables into your Uniface repository, you unlock the ability to perform powerful cross-referencing queries. This allows you to quickly answer critical questions like:
* Which components interact with a particular entity, such as CUSTOMER?
* Where is a specific field, like TOTAL_PRICE, being modified within your scripts?
* Identify all services that invoke a particular operation, for instance, GET_USER_DATA.
This functionality is indispensable for pre-emptively assessing the potential impact of any proposed changes to your application.
The Essential Function: $ude("import", "symboltable")
The cornerstone of populating this valuable cross-reference data is the $ude function, a versatile utility within Uniface. Specifically, its import action, combined with the symboltable argument, facilitates the loading of symbol table data directly into the UXCROSS.DICT repository table.
The general syntax for this operation is:
vResult = $ude("import", "symboltable", "ResourceProfile", "", "OptionsList")
Let’s explore its practical application.
A Practical Example: Importing Specific Symbol Tables
Consider a scenario where you need to import symbol table information for all compiled objects within your MY_LIB library, specifically those whose names begin with CUST_. The following ProcScript demonstrates how to achieve this:
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
In this $ude call:
* “import”, “symboltable”: Defines the action to import symbol table data.
* “CUST_*”: Serves as the ResourceProfile, employing a wildcard to target all compiled objects prefixed with “CUST_”. This is highly effective for batch processing.
* “”: This fourth parameter is unused in this context and left empty.
* “library=MY_LIB”: Specifies the OptionsList, indicating that the objects belong to the MY_LIB library.
Refining Imports with Resource Types
For more granular control, you can restrict the import to specific resource types, such as only services or forms. This is accomplished by appending a ResourceType\ to the second parameter.
For example, to import symbols exclusively for the ORD_DETAIL component:
; The resource type is 'component'
vResult = $ude("import", "symboltable;component", "ORD_DETAIL", "", "")
Commonly used resource types include:
* component
* form
* service
* report
* model (for modeled entities)
Verifying Operation Success
The return value of the $ude function provides immediate feedback on the operation’s outcome:
* A value of 0 or greater (>= 0) signifies successful execution, with the number indicating the count of records processed.
* A negative value (< 0) indicates that an error occurred.
In the event of an error, it is crucial to consult the built-in ProcScript functions $procerror and $procerrorcontext. These functions deliver precise error codes and detailed messages, which are invaluable for debugging.
Conclusion
The judicious use of $ude("import", "symboltable") is a foundational practice for harnessing Uniface\’s powerful cross-referencing capabilities. It significantly enhances your ability to maintain, understand, and develop complex Uniface applications, transforming what could be a daunting task into a manageable process. This seemingly minor utility proves to be a critical asset for large-scale projects.