From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 24-AUG-1990 18:48:42.91
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Re: VMS Questions- can life be simplified [includes SETPATH.COM]

Received:  by crdgw1.ge.com (5.57/GE 1.70)
	 id AA09650; Fri, 24 Aug 90 18:30:34 EDT
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Fri, 24 AUG 90 14:23:51 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA20496; Fri, 24 Aug 90 14:17:27 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 24 Aug 90 20:36:47 GMT
From: pasteur!agate!agate!jym@ucbvax.Berkeley.EDU  (Jym Dyer)
Organization: Berserkeley
Subject: Re: VMS Questions- can life be simplified [includes SETPATH.COM]
Message-Id: <JYM.90Aug24133647@remarque.berkeley.edu>
References: <9008241356.AA21846@ucbvax.Berkeley.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

.-.
|N|OTE:  There's some worthwhile freeware at the end of this
`-' message.

> what I would really like is to be able to do offsets
.-.
|Y|ou would need to define a logical like this:
`-'
	DEFINE HOME SYSTEM$DISK:[USERS.ADMIN.RAY.WORKING.]

    Then you could do offsets like HOME:[PROGRAMS.PASCAL.PROJ1].
.-.
|Y|ou can almost get logicals to work with offsets as well as
`-' refer to the root directory by specifying them in a list:

	DEFINE X DISK2_:[JYM],DISK2_:[JYM.]

    This has weird side-effects, though.  And you get slightly
    different results if you change the order:

	DEFINE X DISK2_:[JYM.],DISK2_:[JYM]

    (The latter works well for #include file paths, by the way.)
    I don't do this (because of the weird side-effects); I use
    two logicals:

	DEFINE J_ DISK2_:[JYM.]
	DEFINE J  J_:[000000]    ! Or it could be DISK2_:[JYM].
.-.
|B|y the way, you can get MAIL to put its files in a subdirectory
`-' of SYS$LOGIN.  I believe the MAIL command is "SET MAIL_DIRECT-
    ORY" or somesuch.

> Can anyone tell me of a way I can just direct the system to
> search the directory for any @xxxxxx programs I execute?
.-.
|A|s luck would have it, I wrote a program to do that just last
`-' week!  It creates command symbols for all or some of the
    command procedures and/or executables in a given directory.
    Lots of comments at the end.  Share and enjoy.
    <_Jym_>
-----------------8<--------cut-here----------8<-------------------
$ verify_context = 'f$verify(0)'
$ status = %x10000001			! SS$_NORMAL (inhibited)
$ on control_y then goto ADIOS
$ on error then continue
$ echo = "write sys$output"
$ msg = "write sys$error"
$!
$ is_verbose = 0
$ if (f$edit(p1,"lowercase") .eqs. "-v")
$ then
$   is_verbose = 1
$   p1 = p2
$ endif
$!
$CHECK_P1:
$ if (p1 .eqs. "?")
$ then
$   echo "path of directory whose .com and .exe files you want to make"
$   echo " command symbols for"
$   echo "or path with (usually wildcarded) file-specification"
$   p1 = ""
$ endif
$ if (p1 .nes. "") then goto P1_CHECKED
$ !{
$   read/end_of_file=ADIOS/error=ADIOS/prompt="_Path: " sys$command p1
$   goto CHECK_P1
$ !}
$P1_CHECKED:
$!
$ raw_path = f$parse(p1,,,,"syntax_only")
$ if (f$parse(raw_path) .eqs. "")
$ then
$   msg f$message(%x000186d4)		! RMS$_SYN
$   msg "  \''p1'\"
$   status = %x1000186d4		! RMS$_SYN (inhibited)
$   goto ADIOS
$ endif
$ path = f$parse(raw_path,,,"device") + f$parse(raw_path,,,"directory") + -
   f$parse(raw_path,,,"name")
$ raw_type = f$parse(raw_path,,,"type")
$ if (raw_type .nes. ".") then -
   path = path + raw_type
$ if (is_verbose .ne. 0) then -
   echo "Path: " + path
$!
$ file = f$parse(path,"*.exe")
$LOOP_EXE:
$ this_file = f$edit(f$search(file),"lowercase")
$ if (this_file .eqs. "") then goto BREAK_EXE
$ !{
$   this_file = this_file - f$parse(this_file,,,"version")
$   symbol = f$parse(this_file,,,"name")
$   gosub HYPHEN_TO_UNDERSCORE
$   'symbol' == "$" + f$edit(this_file,"lowercase")
$   if ($severity .eq. 1) then goto SHOW_EXE
$   !{
$     msg "  \''symbol'\"
$     goto LOOP_EXE
$   !}
$SHOW_EXE:
$   if (is_verbose .ne. 0) then -
     echo f$edit("''symbol' == ""$''this_file'""","lowercase")
$   goto LOOP_EXE
$ !}
$BREAK_EXE:
$!
$ file = f$parse(path,"*.com")
$LOOP_COM:
$ this_file = f$edit(f$search(file),"lowercase")
$ if (this_file .eqs. "") then goto ADIOS
$ !{
$   this_file = this_file - f$parse(this_file,,,"version")
$   symbol = f$parse(this_file,,,"name")
$   gosub HYPHEN_TO_UNDERSCORE
$   'symbol' == "@" + f$edit(this_file,"lowercase")
$   if ($severity .eq. 1) then goto SHOW_COM
$   !{
$     msg "  \''symbol'\"
$     goto LOOP_COM
$   !}
$SHOW_COM:
$   if (is_verbose .ne. 0) then -
     echo f$edit("''symbol' == ""@''this_file'""","lowercase")
$   goto LOOP_COM
$ !}
$!
$ADIOS:
$ exit (status + (0 * f$verify(verify_context)))
$!
$HYPHEN_TO_UNDERSCORE:			! Subroutine
$ length = f$length(symbol)
$ if (f$locate("-",symbol) .eq. length) then return
$ i = 0
$ new_symbol = "!"			! Character not found in filespecs.
$LOOP_HYPHEN:
$ element = f$element(i,"-",symbol)
$ if ("''element'" .eqs. "-") then goto BREAK_HYPHEN
$ !{
$   new_symbol = new_symbol + "_''element'"
$   i = i + 1
$   goto LOOP_HYPHEN
$ !}
$BREAK_HYPHEN:
$ symbol = new_symbol - "!_"
$ return
$!
$!/* SETPATH.COM
$!**===========================================================================
$!** Facility:	None
$!**---------------------------------------------------------------------------
$!** Prefix:	setpath:
$!**---------------------------------------------------------------------------
$!** Abstract
$!** ~~~~~~~~
$!**  SETPATH creates command symbols for command procedures (.com files)
$!** and/or executable images (.exe files) in a specified directory path.
$!** This is somewhat akin to the Unix practice of setting the path and/or
$!** PATH environment variables to include a specified directory path
$!** (though SETPATH allows you a bit more control).
$!**---------------------------------------------------------------------------
$!** Usage
$!** ~~~~~
$!**		@setpath [-v] <path>[<filespec>]
$!**
$!**  In its simplest form, SETPATH is simply executed with one argument, the
$!** path to a directory full of command procedures and/or executable images:
$!**
$!**		@setpath disk1_:[toys]
$!**
$!** This will create command symbols to execute all of the programs in the
$!** DISK1_:[TOYS] directory.  The command symbols are the programs' filenames.
$!** For example, if that directory contains the files FOO.EXE and BAR.COM,
$!** SETPATH will create a FOO command symbol and a BAR command symbol.
$!**  You can use the verbose ("-v") option to make SETPATH display the command
$!** symbols it creates.  If we use it with our previous example:
$!**
$!**		@setpath -v disk1_:[toys]
$!**
$!** SETPATH will make a display like this:
$!**
$!**		Path: DISK1_:[TOYS]
$!**		foo == "$disk1_:[toys]foo.exe"
$!**		bar == "@disk1_:[toys]bar.com"
$!**
$!**  You can specify filename and filetype information to select programs
$!** from a directory to assign commands to.  Wildcards can be used.  These
$!** examples show how useful this is:
$!**
$!**		@setpath dev3_:[tools]*.com
$!**		@setpath dev3_:[tools].exe
$!**		@setpath dev3_:[tools]fix_*
$!**		@setpath dev3_:[tools]*tty*.exe
$!**
$!** The first two show how you can create commands for only the command
$!** procedures or the executables in a directory; it works with or without
$!** the "*" filename.  The last two demonstrate how to get commands for
$!** programs selected by their names:  tools prefixed with "fix_", or all
$!** tools with "tty" in them.
$!**  The following are examples of not-so-useful paths:
$!**
$!**		@setpath dev3_:[tools]*.*
$!**		@setpath dev3_:[tools];7
$!**		@setpath dev3_:[tools]*.run_me
$!**
$!** The first example is redundant; the wildcards are unnecessary.  The second
$!** is meaningless; version numbers are ignored.  The third is meaningless;
$!** SETPATH only knows how to run .com and .exe files.
$!**  SETPATH can be used to create a command for one specific program:
$!**
$!**		@setpath dev3_:[tools]xyzzy.exe
$!**
$!** It will usually be easier to type in the command symbol definition by
$!** hand, though.
$!**  The directory paths you specify should be chosen with care.  SETPATH is
$!** handy for directories of tools for specific projects.  Creating command
$!** symbols for every program in a large directory (SYS$SYSTEM, for example),
$!** will just fill up your process space with commands you won't use---and
$!** perhaps with commands that won't work (attempting to run shareable images
$!** and such).
$!**  Note:  SETPATH creates command symbols for the executable images (.exe)
$!** first and the command procedures (.com) second.  If a directory has a .com
$!** file and a .exe file with the same filename, the command symbol you end up
$!** with will execute the .com file.  The assumption is that the .com file is
$!** more likely to be a user-friendly front-end to the .exe file---if this is
$!** not the case, you can reverse the order by executing SETPATH twice and
$!** specifying the .com and .exe filetypes in the argument:
$!**
$!**		@setpath mydisk:[weird_dir].com
$!**		@setpath mydisk:[weird_dir].exe
$!**
$!**  Note:  Program names can have hyphens in them, but command symbols can't.
$!** When SETPATH encounters a program name with hyphens in it, it creates a
$!** command symbol with underscores in place of the hyphens:
$!**
$!**		@setpath -v sy0_:[stuff]crash*
$!**		Path: SY0_:[STUFF]
$!**		crash_the_image == "@sy0_:[stuff]crash-the_image.com"
$!**		crash_the_machine == "$sy0_:[stuff]crash_the_machine.exe"
$!**		crash_the_process == "$sy0_:[stuff]crash-the-process.exe"
$!**
$!**---------------------------------------------------------------------------
$!** Environment
$!** ~~~~~~~~~~~
$!**  It is possible for existing abbreviated symbols to conflict with the
$!** command symbols created by SETPATH.  In such cases, SETPATH will display
$!** a warning message and leave the old symbol intact.
$!**---------------------------------------------------------------------------
$!** Author:	Jym Dyer - 14-Aug-1990
$!**---------------------------------------------------------------------------
$!** Modifications
$!** ~~~~~~~~~~~~~
$!** 1.0-001 - Original version.  {Jym 14-Aug-1990}
$!**===========================================================================
$!*/

