DEV Community

Peter + AI
Peter + AI

Posted on

Demystifying Uniface 10.4's $ude("lookup") Function ✨

Disclaimer: This blog post was created with the help of an AI to make the Uniface 10.4 documentation more accessible and easier to understand.

Hey developers! 👋 If you're working with Rocket Uniface 10.4, you know it's a powerful platform for building enterprise applications. But have you ever needed to check if a compiled component, message, or another resource actually exists before your code tries to use it? That's where the $ude("lookup") function comes in. It's like having a superpower to peek into your compiled application files! 🦸‍♂️

Let's break down this incredibly useful function in simple terms.

What is $ude("lookup")? 🤔

In short, $ude("lookup") is a built-in Uniface function that lets you search for compiled runtime objects. Think of your Uniface application as a big library. Before you go looking for a specific book, you'd check the library's catalog first. $ude("lookup") is your digital card catalog! 📇

You can use it to find out if things like components, global ProcScript, messages, or menus have been compiled and are ready to be used. This prevents errors and allows you to build more dynamic and robust applications.

The Basic Syntax ⚙️

The function looks a bit complex at first, but it's quite logical once you break it down:

$ude("lookup", "Type;ResourceType", ResourceProfile, "", {OptionList})

  • "lookup": This is the fixed part that tells Uniface what you want to do.
  • Type;ResourceType: This tells Uniface what you're looking for.
    • Type can be resources_output (for compiled objects), symbolTable, or listing. Most of the time, you'll use resources_output.
    • ResourceType is the specific object type, like form, service, message, or menu.
  • ResourceProfile: This is the name of the object you're searching for, for example, "MY_FORM".
  • OptionList: These are extra filters to narrow down your search. This is super important for global objects! Common options include:
    • library=MyLib
    • language=en (for language-specific objects like messages)

A Practical Example 🎬

Let's look at an example from the documentation and see what it really means.

vResourceList = $ude("lookup", "resources_output;message", "generror", "", "library=MyLib;language=fr")

Here’s what we are asking Uniface to do, step by step:

  1. Hey Uniface, please look up... ("lookup")
  2. ...a compiled runtime object that is a message... ("resources_output;message")
  3. ...named "generror". ("generror")
  4. And to be more specific, please check inside the library named 'MyLib'... ("library=MyLib")
  5. ...for the French version of that message. ("language=fr") 🇫🇷

What Do You Get Back? 🎁

The function is very direct. It gives you one of two things:

  • A List of Resources: If it finds one or more matching objects, it returns a string containing a list with all the details for each found object, like this: "TYPE=Form!;NAME=MYFORM1!;LIBRARY=!;LANGUAGE=!;CLASS=;"
  • Zero (0): If it finds absolutely nothing that matches your criteria, it simply returns 0.

This makes it incredibly easy to check the result in your ProcScript:


vResult = $ude("lookup", "resources_output;form", "MY_MISSING_FORM", "", "library=MY_APP_LIB")

if (vResult = "0")
  message "Oops! The form 'MY_MISSING_FORM' could not be found. 🙈"
else
  ; Great, the form exists! Let's do something with it.
  newinstance "MY_MISSING_FORM", ...
endif
Enter fullscreen mode Exit fullscreen mode

Why Should You Care? 🤔

This function is more than just a lookup tool. It's a key to building smarter applications.

  • Error Prevention: Check if a component exists before you try to create an instance of it. No more fatal errors from missing objects!
  • 🛠️ Developer Tools: You can build your own utility components that list all compiled objects in a certain library. This is fantastic for debugging and managing large projects.
  • 🚀 Dynamic Deployment: You can write scripts to verify a deployment by checking if all the necessary components, messages, and services are present in the runtime environment.

So, next time you need to make sure a resource is available, don't just hope for the best. Use $ude("lookup") and know for sure! Happy coding! 💻

Top comments (0)