Saturday, 29 September 2012

Undocumented feature - assignment files

I was asked yesterday if I knew about the Uniface function $assignments.  I did and it's something that we started using as soon as it became available (from version 9.something) and it's incredibly useful.  I searched the manuals so that I could send the enquirer the details, but I couldn't find any reference to it.

When a userver starts up, it reads the assignment file in order to get numerous settings.  There are many sections, including a custom section called "logicals", which allows you to add your own assignment files settings, which can be read using the $logical function.  

It is now possible to list all of the logicals at once, like this...

  list = $assignments("LOGICALS")

This returns a Uniface list of all the logicals.  It is possible to return any section of the assignment files in this way, including "paths", "files" and "services_exec".

This was mentioned on the Hacking UnifAce blog over a year ago, but hopefully you find it useful.

Summary: You can access the assignment file settings in code, listed by their section, which can be useful for checking which settings the current userver is using.

1 comment:

  1. .. a quick amendment.

    $assignment is what uniface assembles from a couple of ASN Files (like usys.asn etc.)

    And if you have identical lines, the new ones will replace the older ones.

    So sometimes you may be surprised when lines are listed which you can not find in "your" ASN file. Or lines do not have the values as you see it in the ASN file.

    Especially (because it works on a first fit) is when you use file redirections with wildcards.