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

Simply variable problem

Go to solution
Martin Brindle
Occasional Advisor

Simply variable problem

Hi, I'm struggling to do something that I suspect is utterly simple, so good opportunity for some points for someone!

If I define a logical like this, which concats two parameters

define test 'P1''P2'

how do I then access test to get the contents?

for example to move a file of that combined name

rename [here]test [there]test

Like in unix you would prefix with a $.


Karl Rohwedder
Honored Contributor

Re: Simply variable problem


logical names are transparently interpreted by RMS, so just do a

$ rename [here]logical [there]logical

(assume that here and there are on the same phy. disk!)

regards Kalle
Robert Gezelter
Honored Contributor

Re: Simply variable problem


The phrasing in your post is somewhat unclear to me. Some possible interpretations:

Assume the following:
P1 = "A"
P2 = "B"

$ DEFINE TEST 'P1''P2' yields "AB" as the value of TEST

$ DEFINE TEST 'P1','P2' yields two values (accessible using F$TRNLNM with the index parameter) of "A" and "B" respectively. The SHOW LOGICAL command will show the value as "A","B"

The syntax for concatenation is A+B (or A,B) in the COPY command. To build a command to iterate down the contents of the logical name TEST, you would start with a null string and then concatenate the values in TEST one at a time with the appropriate punctuation. Then use the resulting string as the source parameter of the COPY command.

The above presumes that I have interpreted the posting correctly. If I have not, please let me know.

- Bob Gezelter, http://www.rlgsc.com
Daniel Fernandez Illan
Trusted Contributor

Re: Simply variable problem


You can use this command to execute a rename:

$ define test 'p1','p2' !define logical name
$io1=f$trnlnm("test",,0) !Obtain first value
$io2=f$trnlnm("test",,1) !Obtain second value
$rename [here]'io1' [there]'io2'

(Remember that rename only works on the same physical disk)


Respected Contributor

Re: Simply variable problem

If I understood your question, you just simply want to use the concatenated logical name definition in your rename command, so...

$ rename [here]'f$trnlnm("test") [there]

Hope that helps.
Respected Contributor

Re: Simply variable problem

I just noticed Karl's response (the first response) and that's your best bet.
Jon Pinkley
Honored Contributor

Re: Simply variable problem

If the [here] and [there] were referring to VMS directories, then logical names won't do what you want.

$ p1 = "ABC"
$ p2 = ".DAT"
$ define test 'P1''P2'
$ sho log test
$ cre/dir disk$jscratch:[here]
$ cre/dir disk$jscratch:[there]
$ set def disk$jscratch:[here]
$ cre test
Exit ! Control Z
$ dir/siz=all/date/wid=(file:38,size=7)


ABC.DAT;1 0/0 15-MAR-2007 08:20:25.17

Total of 1 file, 0/0 blocks.

Appears to have done what you want, but that's not the whole story.

$ ren [here]test [there]test/log
-RMS-E-FNF, file not found

Here filename parsing is confused because of part of the string looks like the directory portion of a file spec.

You probably want to use DCL symbols instead of a logical name.

$ test := 'p1''p2'
$ sho symbol test ! symbols are more like unix environment variables
$ ren [here]'test' [there]'test'/log

If you have a logical name and you want to convert to a DCL symbol, user F$TRNLNM (see help lexical f$trnlnm)

Other differences between rename and mv. Rename can only rename to the same device. If there is the possibility that [here] and [there] are on different devices, you will need to use something like backup /delete.
it depends
Honored Contributor

Re: Simply variable problem

There's a write-up on symbols and on logical names in the FAQ. It's a common confusion for folks coming over from Unix; the DCL stuff looks really familiar, but different.

I considered posting the section here, but it's about a dozen paragraphs, excluding the sections on arguments and argument lists and other such that follow.

The FAQ is available at:

See the section "DCL Details"

Stephen Hoffman