HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Simply variable problem

 
SOLVED
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 $.

Thanks,

Martin
7 REPLIES
Karl Rohwedder
Honored Contributor
Solution

Re: Simply variable problem

Martin,

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

Martin,

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

Martin

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)

Saludos.
Daniel.


EdgarZamora_1
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.
EdgarZamora_1
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
"TEST" = "ABC.DAT" (LNM$PROCESS_TABLE)
$ 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)

Directory DISK$JSCRATCH:[HERE]

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
%RENAME-E-SEARCHFAIL, error searching for DISK$JSCRATCH:[HERE]TEST.;
-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
TEST = "ABC.DAT"
$ ren [here]'test' [there]'test'/log
%RENAME-I-RENAMED, DISK$JSCRATCH:[HERE]ABC.DAT;1 renamed to DISK$JSCRATCH:[THERE]ABC.DAT;1
$

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
Hoff
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:
http://www.hoffmanlabs.com/vmsfaq/

See the section "DCL Details"

Stephen Hoffman
HoffmanLabs