Hey Uniface developers! π Are you still manually compiling your components, entities, and other objects in the IDE? What if I told you there's a way to automate this entire process right from your ProcScript code? Let's dive into the powerful $ude("compile") function.
Disclaimer: This blog post was created with the help of an AI assistant, based on the official Uniface 10.4 documentation, to make the information more accessible.
What is $ude("compile") Anyway? π€
In simple terms, $ude("compile") is a built-in ProcScript function that allows you to programmatically compile your development objects. Think of it as triggering the compiler from your code instead of clicking through the IDE menus. This is incredibly useful for creating automated build scripts, continuous integration pipelines, or simply streamlining your development workflow.
The basic syntax looks like this:
vResult = $ude("compile", ObjectType, ObjectProfile, "", OptionList)
Breaking Down the Parameters π§©
Let's quickly look at what each part does:
- ObjectType: This tells Uniface what kind of object you want to compile. Examples include
"component","entity","menu", or"proc". - ObjectProfile: This specifies which objects to compile. You can use wildcards! For instance,
"CUST*"would compile all objects whose names start with "CUST". - OptionList: This is an optional associative list for extra instructions. You can specify a library, set a message level, or define other compiler behaviors.
Practical Examples π»
Theory is great, but let's see it in action. Here are a few common use cases.
Example 1: Compile a Single Entity
Imagine you've made a change to an entity named "CUSTOMERS" in the "SALES" model and want to compile it.
vResult = $ude("compile", "entity", "CUSTOMERS.SALES", "")
if (vResult < 0)
message "Oops! Compilation failed. Check $procerrorcontext for details."
endif
This command specifically targets one entity and compiles it. We also check the return value (vResult) to see if an error occurred.
Example 2: Compile Multiple Components
Let's say you want to compile all components that start with "INV_". You can use a wildcard for that.
vResult = $ude("compile", "component", "INV_*", "", "messagelevel=0")
Here, we are compiling all components matching the "INV_*" profile. We also added an option to the OptionList: "messagelevel=0" shows all messages (Info, Warning, and Error), which is great for debugging.
Example 3: Compile Global Objects in a Library
You can also compile global objects like menus or messages. This example compiles all menus within a specific library named "MY_UI_LIB".
vResult = $ude("compile", "menu", "", "", "library=MY_UI_LIB")
Notice that the ObjectProfile is empty, which means "all objects of this type". The library option in the OptionList scopes the operation to just that library.
Common Problems and Pitfalls β οΈ
Using $ude is powerful, but there are a couple of things to keep in mind:
- Environment Matters: The
$udefunctions require a fully configured Uniface Repository and depend on functionality fromide.uar. This means they are intended to be run in a development environment on Windows (usingide.exeor with the UAR file included in your application's resources). They won't work in a lean runtime environment. - Check for Errors: Don't just fire and forget! The function returns a value (
>=0for success,<0for failure). If an error occurs, the real details are hiding in the$procerrorand$procerrorcontextfunctions. Always check these to understand what went wrong. The$procreturncontextfunction is also your best friend for getting detailed feedback on what was compiled.
Conclusion β¨
Automating your compilation process with $ude("compile") can save you a ton of time and reduce manual errors. It's a key step towards creating more professional and robust build processes in your Uniface projects. Give it a try!
Happy coding! π
Top comments (0)