🧑💻 Complex Usage Examples
1️⃣ Operations with Variable Names
You can dynamically pass the operation name as a variable:
Code:
$vOperation$ = "do_it"
activate "myCptInstance".$vOperation$()
Or with a local variable:
vOperation = "do_it"
activate "myCptInstance"."%%vOperation%%%"()
2️⃣ Passing Typed Lists with /list
With /list
, you can pass multiple parameters as typed lists, e.g., for service operations:
Code:
putitem vInParms, -1, $date(20250101)
putitem vInParms, -1, $number(5)
activate/list "SERV2".ADD_WEEK(vInParms, vOutParms)
After the call, vOutParms
contains the result.
3️⃣ Working with Entities and Occurrences
You can pass entire entities or occurrences to an operation:
Code:
setocc "PO_ITEMS", -1
activate "SERV2".TOTAL_LNS("PO_ITEMS")
🖥️ Special Cases & Noteworthy Features
Modal Forms
- Only certain operations can be activated in modal forms.
- The
EXEC
operation can be started from outside, others mostly only internally.
Code:
activate "MyModalForm"
Executing Operating System Commands
With a special service signature, you can start OS commands via activate:
Code:
activate "OS_SERVICE".COMMAND("dir C:")
Exception Handling
If an activated operation throws an exception, it is propagated to the activate statement.
You can use try/catch to handle errors:
Code:
try
activate "MyCpt".do_it()
catch
message "Exception: " + $procerror
endtry
📝 Practical Tips
- Use variables for operation names to keep your code flexible.
- With
/stateless
, you can call services statelessly and efficiently. - Always check
$status
and$procerror
after every activate call for robust error handling.
This post is based on the official Uniface 10.4 documentation and was created with AI support. For details, see the original documentation.
What special cases have you solved with activate? Share your experiences in the comments! 👇
Top comments (0)