Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

F$TRNLNM not returning expected strings

 
Michael Carlton
Occasional Visitor

F$TRNLNM not returning expected strings

Hi all

Need some help here. I have a logical name that is defined with multiple strings. When I do a translation of this, it only returns the first string.

Here is the sequence being used:

PROTON::NC6926> DEF/SYSTEM BACK$UDT_EXCLUDE_USERS E38589, 10697, 47646

PROTON::NC6926> Show Logical BACK$UDT_EXCLUDE_USERS

BACK$UDT_EXCLUDE_USERS" [super] = "E10697"
= "E38589"
= "E47646"


PROTON::NC6926> tt = F$EDIT(F$TRNLNM("BACK$UDT_EXCLUDE_USERS"),"UPCASE")
PROTON::NC6926> show sym tt
TT = "E38589"

This is in a script that WAS working at one time. Now it does not.
I have tried deassigning the name, assigning it using /exec and /system, have specified specific logical name tables and anything else I can think of.

I am running a V7.3-2 cluster.

Any thoughts as to why this happens?

Thanks
Mike Carlton
10 REPLIES 10
Thomas Ritter
Respected Contributor

Re: F$TRNLNM not returning expected strings

Are you sure the user names were not inside a string "E38589,10697,47646" originally ? What you have is a search list, used for locating files.
Try putting the users inside a string and then
$ write sys$output
F$TRNLNM("BACK$UDT_EXCLUDE_USERS")
Graham Burley
Frequent Advisor

Re: F$TRNLNM not returning expected strings

$ help lex f$trnlnm arg

You need to specify an INDEX.
Jan van den Ende
Honored Contributor

Re: F$TRNLNM not returning expected strings

Mike,

Grahem gave you the formally correct answer.

That may be enough.

But if the desired result would be
show sym tt
TT = "E38589, 10697, 47646"

Then you should do
DEFINE/SYSTEM BACK$UDT_EXCLUDE_USERS "E38589, 10697, 47646"

Notice that the total value string is enclosed by ONE pair of double quotes.

(a side result will be case preservation in the translation result; but you cured that already with the F$EDIT)

A side remark: if this is in a script, do yourself (and especiallly your collegues!) a big favor and do NOT abbreviate commands, and more so, NEVER shorten to less than 4 characters.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Jan van den Ende
Honored Contributor

Re: F$TRNLNM not returning expected strings

Oops!
Same omission twice a day :-(

I should have begun with:

WELCOME to the VMS forum.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Michael Carlton
Occasional Visitor

Re: F$TRNLNM not returning expected strings

Hi Tom,
No these are not inside a string (at least as far as I can tell).
This is part of a larger set of scripts that manage a Unidata backup. These were written some time ago, probably under V5 and have not been modified since.
For some reason, the users are just now complaining about this. What it is supposed to do is take a list of users and use that list to create a script that logs users off the system.

As this cluster environment here is new to me, I can't really say what else is going on. Still trying to get a handle on the multitude of scripts that they have running.


Michael Carlton
Occasional Visitor

Re: F$TRNLNM not returning expected strings

Hi jan

Thanks for the welcome. It has been several years since I've done VMS system mgmt so I may be a bit rusty in some things.

The original define command does not use the double quotes in defining this logical.

DEF BACK$UDT_EXCLUDE_USERS E38587, E10697, E47646

I will take your advice and change the DEF to the full DEFINE in this procedure. As mentioned, these were all written many years ago for a VAX/VMS V5.3 environment. (circa 1999). There have been some updates to account for the fact that they are now running on an ALPHA V7.3-2 system. I suppose I should look at the script that uses the logical to see how they originally expected to see the list.
My original post showed how the system displayed the logicals so I would suspect they wanted the user list as a list.
This most likely has not worked correctly since the upgrade but has gone unnoticed until now.

I will let you know my results.

Robert Gezelter
Honored Contributor

Re: F$TRNLNM not returning expected strings

Mike,

I will wholeheartedly agree with Jan. The programming to process the strings will be significantly different depending on whether it is outside quotes (creating a search list, which must be processed using the index parameter) or a quoted string (which would be processed in a number of other ways, including using F$ELEMENT).

I strongly recommend searching for all uses of the BACK$UDT_EXCLUDE_USERS logical name and checking how it is used. For that matter, also check that it is used consistently.

- Bob Gezelter, http://www.rlgsc.com
John Gillings
Honored Contributor

Re: F$TRNLNM not returning expected strings

Mike,

At the risk of stating the obvious. Although solutions have been suggested, no one has clearly stated the issue, so here goes:

On OpenVMS logical names can have multiple translations, known as a "search list". When the translations are device and/or directory specifications, a logical name translation in a file specification will "walk" the search list until a match is found. For example, assume the logical name is defined as:

$ DEFINE MYLOG DISK1:[DIR1],DISK2:[DIR2],DISK3:[DIR3]

The command:

$ TYPE MYLOG:AFILE.TXT

will look for a file called AFILE.TXT in DISK1:[DIR1], if found that file will be displayed. If not found, DISK2:[DIR2] is searched, and so on. It's a way to make multiple devices and or directories appear to be a single entity.

HOWEVER, the command:

$ CREATE MYLOG:NEWFILE.TXT

will only ever create the file in the first entry in the search list, DISK1:[DIR1]. Also any request to translate the logical name without specifying which entry in the list will return only the first entry (index 0).

If you want to translate the whole list, you'll need to traverse the list. Here's an example:


$ name="BACK$UDT_EXCLUDE_USERS"
$ tt=F$EDIT(F$TRNLNM(name),"UPCASE")
$ IF tt.EQS."" THEN GOTO Finished
$ i=1
$ Loop:
$ te=F$EDIT(F$TRNLNM(name,,i),"UPCASE")
$ IF te.NES.""
$ THEN
$ tt=tt+","+te
$ i=i+1
$ GOTO Loop
$ ENDIF
$ Finished:
$ SHOW SYM tt


Note that this doesn't deal with the issue of an entry containing an embedded comma.

(Logical name search list manipulation is a rather weak area in DCL. This makes writing modular code which does things like add a translation to LNM$FILE_DEV or LNM$LIBRARY rather convoluted. Many years ago I proposed the addition of qualifiers for DEFINE to allow appending and prepending a list, inserting and deleting entries. Unfortunately Guy didn't get that far down the stack before he left...)
A crucible of informative mistakes
Thomas Ritter
Respected Contributor

Re: F$TRNLNM not returning expected strings

Michael, you wrote
"This is in a script that WAS working at one time. Now it does not. "

Would you be able to post the script or just an extract ?