OpenVMS DCL Command Procedure :
$!
$! SET_DEFAULT.COM
$!
$! Usage : Place the following line in your SYS$LOGIN:LOGIN.COM file :
$! (symbol name) :== "@(drive & directory location)SET_DEFAULT.COM"
$!
$! (symbol name) (directory name) : changes your account to the specified
$! directory.
$!
$! (symbol name) : prompts you for the directory to change to; by default,
$! the SYS$LOGIN directory is selected.
$!
$! (symbol name) [-] or .. : moves up one directory level.
$!
$! (symbol name) (directory name){.(sub-directory1)}{.(sub-directory2)}... :
$! changes your account to the specified sub-directory.
$!
$! Whenever the (symbol name) command is used, the VMS prompt is set
$! accordingly to reflect the current directory.
$!
$ verification = f$verify( 0 .or. "''SET_DEFAULT_VERIFY'")
$ ON WARNING THEN GOSUB Error_Trap
$ ON CONTROL_Y THEN GOTO Procedure_Exit
$!
$ status_code = 1
$!
$ current_dir = f$environment("DEFAULT")
$!
$ IF f$length( p1 ) .EQ. 0
$ THEN WRITE sys$output f$extract( 0, 11, f$time() ) -
, " Set Default Directory"
$ WRITE sys$output ""
$ ELSE desired_dir = p1
$ GOTO Start_Procedure
$ ENDIF
$
$!
$Prompt_Revised:
$!
$ home_dir = f$trnlnm( "SYS$LOGIN" )
$ READ/PROMPT="Desired directory: <''home_dir'>" -
/END=Procedure_Exit -
sys$command desired_dir
$!
$ IF F$LENGTH( desired_dir ) .EQ. 0
$ THEN desired_dir = home_dir
$ ENDIF
$!
$Start_Procedure:
$!
$! If the directory is UNIX format, then try to obey it
$!
$ IF desired_dir .EQS. ".." THEN desired_dir = "[-]"
$!
$ IF f$locate( "[", desired_dir ) .EQ. f$length( desired_dir ) -
.AND. f$locate( "]", desired_dir ) .EQ. f$length( desired_dir ) -
.AND. f$locate( ":", desired_dir ) .EQ. f$length( desired_dir )
$ THEN IF F$TRNLNM( desired_dir ) .EQS. ""
$ THEN desired_dir = "[." + desired_dir + "]"
$ ENDIF
$ ENDIF
$!
$ SET DEFAULT 'desired_dir'
$!
$ new_directory = f$environment("DEFAULT")
$ IF F$LENGTH( F$PARSE( new_directory ) ) .EQ. 0 -
.AND. F$SEARCH("*.*") .EQS. ""
$ THEN WRITE sys$output "Desired directory does not exist"
$ desired_dir = current_dir
$ SET DEFAULT 'desired_dir'
$ ENDIF
$!
$ new_directory = f$environment("DEFAULT")
$!
$! If the prompt is to long then, truncate it.
$!
$ prompt_str = new_directory + " $ "
$ IF f$length( prompt_str ) .GT. 32
$ THEN prompt_str = f$extract( f$length( prompt_str ) - 31 -
, 32, prompt_str )
$ ENDIF
$!
$ SET PROMPT = "''prompt_str'"
$!
$!
$Procedure_Exit:
$!
$ IF f$length( p1 ) .EQ. 0
$ THEN WRITE sys$output ""
$ WRITE sys$output "All done"
$ ENDIF
$!
$! verification = f$verify( verification )
$!
$ EXIT status_code .OR. %x10000000
$!
$! Capture the status code, but continue on warnings
$!
$Error_Trap:
$!
$ status_code = $STATUS
$ IF ( status_code .AND. 7 ) .EQ. 0
$ THEN RETURN
$ ENDIF
$!
Error_Exit:
$!
$ GOTO Procedure_Exit
This page hosted by
Get your own Free Homepage