Operating System - OpenVMS
1825677 Members
3724 Online
109686 Solutions
New Discussion

Using variable to set def directory

 
SOLVED
Go to solution
gibson
New Member

Using variable to set def directory

Is there some way within a DCL command procedure to pass a variable to the set default direcory command.

for example

$newdir = test1
$set def sys$sysdeivce:[stuff.mine.newdir]

where newdir is a variable name
4 REPLIES 4
Heinz W Genhart
Honored Contributor
Solution

Re: Using variable to set def directory

Hi Gibson

$ newdir = "test1"
$ SET DEF sys$syssdevice:[stuff.mine.'newdir']

This will do what you expected.

or ...

$ @my_commfile "test1" ! Supply the variable part as a variable to the commfile

The commfile then looks like this:

$ SET DEF SYS$SYSDEVICE:[stuff.mine.'P1']


Hope that helps

Regards

Heinz

Hoff
Honored Contributor

Re: Using variable to set def directory

Hello and Welcome to ITRC.

DCL symbol substitution will be of interest here, and applies here and most any other time when the $ prompt or DCL is otherwise reading and processing input:

$ newdir := SYS$SYSDEVICE:[SOMEWHERE]
$ SET DEFAULT 'newdir'

To perform a substring substitution

$ newdir := test1
$ SET DEFAULT ddcu:[this.that.'newdir']

(or potentially [.'newdir'], if you can use relative directory notation.)

Navigation within a directory hierarchy can be a bit, um, interesting.

Also look around for PUSHD and POPD tools, as these are widely available and potentially relevant here, and there are a gazillion versions of "CD" tools around for OpenVMS. Start on the OpenVMS Freeware, but you should have no problem finding examples using Google or such. (http://www.hp.com/go/openvms/freeware)


As for learning more about DCL and DCL arcana, the OpenVMS User's Guide (in the OpenVMS documentation set) is a good start, and (if you can find a copy) Writing Real Programs in DCL 2nd Ed, a book I co-authored a few years back.

Available tutorial and command-related information is referenced in the OpenVMS FAQ (http://www.hoffmanlabs.com/vmsfaq), for both books and tutorial sites, and comparisions between (say) Unix shell commands and DCL commands.

And again, welcome to ITRC.

Stephen Hoffman
HoffmanLabs
Heinz W Genhart
Honored Contributor

Re: Using variable to set def directory

Hi Gibson

welcome to the forum. I did not recognize that you are a new member.

Have Fun

Regards

Heinz
gibson
New Member

Re: Using variable to set def directory

Your instructions worked like a charm. I have my script running...saved me a bunch of time.

Thanks for your help and friendly welcome to the forum !