(9792) DCL commands and string variables?

Archive of the OpenVMS Ask the Wizard (ATW) questions and answers database.
Locked

Topic author
User
Visitor
Posts: 0
Joined: Mon Jan 10, 2022 8:16 am
Reputation: 0
Status: Offline

(9792) DCL commands and string variables?

Post by User » Wed Aug 11, 2004 9:26 am

Can a DCL command file be used to copy 2 files and give them new names based on
a combination of the user's input variable value and a constant value
contained in the script?

i.e.
user enters a file name of 20040831 in response to a prompt and the DCL command
procedure
copies File1.lis and the procedure names the file EFT20040831.LIS
and procedure
copies File2.lis and procedure names the file ABC20040831.LIS

I have tried using the manual's Basic example for STR$CONCAT and can't get
this to work.


Wizard
Visitor
Posts: 0
Joined: Mon Jan 10, 2022 8:17 am
Reputation: 0
Status: Offline

Re: (9792) DCL commands and string variables?

Post by Wizard » Thu Aug 12, 2004 9:26 am

Both BASIC sommands followed by a call to the convert library (the
callable copy mechanism) or followed by a call to lib$spawn can be
used from within an application. (The OpenVMS WIzard will assume
that one or more BASIC applications are in use here, as the BASIC
RTL call does not generally involve DCL and DCL commands such as
COPY -- applications written in BASIC and in DCL will use entirely
different commands and different syntax, of course.)

Within DCL itself, you would typically use symbols for the specified
task:

Code: Select all

    $ READ/PROMPT="Enter value" SYS$COMMAND tag
    $ COPY file1.lis EFT'tag'.lis
    $ COPY file1.lis ABC'tag.lis
The application can also be coded to create the file under other
names automatically, using either system service or RTL calls
from directly within the BASIC application, or using DCL lexical
functions from within the DCL command procedure. A DCL example follows:

Code: Select all

    $ usrnam  = F$GetJPI(0,"USERNAME")
    $ prcidx  = F$Fao("!4XW",-
                F$GetSYI("MAXPROCESSCNT")-F$GetJPI("0","PROC_INDEX"))
    $ suffix = F$Edit("''usrnam'_''prcidx'","COLLAPSE,UPCASE")
    $ COPY file1.lis EFT'suffix'.lis
    $ COPY file1.lis ABC'suffix'.lis
Examples of DCL code abound here in Ask The Wizard, as well as in
various areas referenced by the OpenVMS FAQ, as well as in the
OpenVMS User's Manual, and in the Digital Press Writing Real
Programs in DCL book.

Locked