DEV Community

Peter + AI
Peter + AI

Posted on

A Simple Guide to Deleting Uniface Objects with $ude("delete") πŸš€

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

Hello, Uniface developers! πŸ‘‹ If you've ever needed to programmatically clean up or manage your compiled application objects, you might have stumbled upon the $ude function. Today, we're going to take a closer look at a specific and very useful operation: $ude("delete").

Let's dive in and make it super simple to understand!

What is $ude("delete")? πŸ€”

In the world of Uniface, $ude is a powerful ProcScript function that lets you interact with the Uniface Development Environment. The "delete" operation specifically allows you to delete compiled runtime objects (like services, forms, and reports), symbol tables, or script listings directly from your code.

Think of it as a way to tell your application: "Hey, go and remove this compiled file from our deployment path (the $RSO path) for me."

The Basic Syntax βš™οΈ

The structure of the function looks a bit intimidating at first, but it's quite logical. Here it is:

vResult = $ude("delete", "Type;ResourceType", ResourceName, "", {OptionList})
Enter fullscreen mode Exit fullscreen mode

Let's break it down:

  • "delete": This tells Uniface the action we want to perform. Easy enough!
  • "Type;ResourceType": This is a two-part string.
    • Type: Specifies what kind of information you're deleting. This is often resources_output for compiled objects.
    • ResourceType: Describes the specific type of object, like component, service, or form.
  • ResourceName: The actual name of the object you want to delete (e.g., "MY_COOL_SERVICE").
  • OptionList: Sometimes, Uniface needs more information, especially for global objects that belong to a specific library or language. This is where you provide those extra details.

Let's See an Example! πŸ’»

The best way to learn is with an example. Imagine you want to delete a compiled service named "MY_SVC". Here's how you'd do it:

vResult = $ude("delete", "resources_output;component;service", "MY_SVC")
Enter fullscreen mode Exit fullscreen mode

Here’s what’s happening in that line:

  • We are telling Uniface to delete...
  • ...a compiled runtime object (resources_output) which is a component of the type service...
  • ...and its name is "MY_SVC".

The result of the operation will be stored in the vResult variable.

What Do the Return Values Mean? βœ…βŒ

After you run the function, the vResult variable will tell you if it worked. This is super important for error handling!

  • 1: Success! The object was deleted. πŸŽ‰
  • 0: The object was not found. Maybe there was a typo in the name or it was already deleted? πŸ€·β€β™‚οΈ
  • <0: An error occurred. Something went wrong. To find out what, you should check the special ProcScript variables $procerror and $procerrorcontext for more details. πŸ•΅οΈβ€β™€οΈ

Handling Global Objects with Options

What if the object you want to delete is a global menu that exists in a specific library and language? This is where the OptionList comes in. For example, to delete a German menu from your common library, your options might look like this:

vOptions = "library=COMMON_LIB;language=DEU"
vResult = $ude("delete", "resources_output;menu", "MAIN_MENU", "", vOptions)
Enter fullscreen mode Exit fullscreen mode

This tells Uniface exactly which version of "MAIN_MENU" to delete.

Conclusion

And that's it! The $ude("delete") function is a straightforward tool for managing your application's compiled resources on the fly. It's great for cleanup tasks or dynamic deployment scenarios.

Happy coding! ✨

Top comments (0)