.; UIC.CMD - SET DEV AND DIRECTORY - JIS 18-MAR-86
.;
.ENABLE SUBSTITUTION,QUIET
.DISABLE DISPLAY
.SETF MOD10
.IFENABLED DECIMAL .SETT MOD10
.IFT MOD10 .DISABLE DECIMAL
.;
.; STORE DEFAULT CLI AND SET USER TO DCL IF NOT ALREADY
.;
.SETS DEFCL <CLI>
.IF DEFCL = "MCR" SET /DCL=TI:
.;
.; CHECK AND STORE DEFAULT MODE (NAMED OR NONAMED)
.; IF NONAMED, SET TO NAMED.
.;
.SETT NAMED
.IF <DIRECT> = "" .SETF NAMED
.IFF NAMED SET DEFAULT/NAMED
.;
.; IF NO PARAMETER ENTERED TO UIC COMMAND, SHOW DEFAULT ONLY.
.; MUST DO THE FOLLOWING IN CASE UIC INVOKED AS @UIC RATHER
.; THAN UIC.  IF @UIC P1 WILL BE THE PARAM, IF UIC P2 WILL BE
.; THE PARAM.  HAS TO DO WITH TDX AND CATCHALL.
.;
.IF P2 = "" .IF P1 = "" .GOTO SHOW
.IF P2 = "" .IF P1 = "UIC" .GOTO SHOW
.IF P1 NE "" .IF P2 = "" .SETS P2 P1
.;
.; SOMETHING WAS ENTERED, SAVE AS INPUT AND PARAM
.;
.SETS PARAM P2
.SETS INPUT P2
.;
.; SAVE ORIGINAL DEFAULT DIRECTORY, IN CASE PROBLEMS.
.;
.SETS DDIR <DIRECT>
.;
.; PARSE PARAM AT COLON, IF FOUND, BRACKET 2ND FIELD IF NECESSARY,
.; CONCATENATE WITH FIRST FIELD, AND SET DEFAULT TO THIS.  THIS TAKES
.; CARE OF THE FOLLOWING CASES: DU:SHULTZ, DU:[SHULTZ], DU:1,54,
.; DU:[1,54], DU:[001054], AND DU:001054
.;
.; THIS FIRST PART CHECKS TO SEE IF ONLY A DEVICE HAS BEEN SPECIFIED.
.;
.TEST PARAM
.SETS END PARAM['<STRLEN>':'<STRLEN>']
.IF END NE ":" .GOTO CONT
SET DEFAULT 'PARAM'
.GOTO SHOW
.;
.; PARAM DOES NOT END IN A COLON, THEREFORE PARSE AT COLON AND CONTINUE
.;
.CONT:
.PARSE PARAM ":" DEV DIR
.IF <STRLEN> NE 2 .GOTO NODEV
.SETS BEG DIR[1:1]
.TEST DIR
.SETS END DIR['<STRLEN>':'<STRLEN>']
.IF BEG NE "[" .SETS DIR "["+DIR
.IF END NE "]" .SETS DIR DIR+"]"
.SETS PARAM DEV+":"+DIR
SET DEFAULT 'PARAM'
.;
.; TEST TO SEE IF DIRECTORY EXISTS.
.;
.SETS TDIR <DIRECT>
.TEST TDIR
.SETN LEN '<STRLEN>'-1
.SETS TESTD TDIR[2:LEN]
.;
.; FIRST CONVERT POSSIBLE G,M SPECIFICATION INTO GGGMMM
.;
.PARSE TESTD "," G M
.IF <STRLEN> NE 2 .GOTO C1
.TEST G
.IF <STRLEN> = 2 .SETS G "0"+G
.IF <STRLEN> = 1 .SETS G "00"+G
.TEST M
.IF <STRLEN> = 2 .SETS M "0"+M
.IF <STRLEN> = 1 .SETS M "00"+M
.SETS TESTD G+M
.;
.C1:
.TESTFILE [0,0]'TESTD'.DIR
.IF <FILERR> NE 1 .GOTO DERR
.GOTO SHOW
.;
.NODEV: 
.;
.; NO DEVICE SPECIFICATION WAS FOUND IN PARAM, LOOK FOR BRACKETS
.; AROUND PARAM, IF THEY ARE THERE, USER IS OBVIOUSLY LOOKING FOR
.; A DIRECTORY BY THAT NAME. IN THIS CASE, SET DEFAULT TO PARAM.
.;
.SETS BEG PARAM[1:1]
.TEST PARAM
.SETS END PARAM['<STRLEN>':'<STRLEN>']
.IF BEG NE "["  .IF END NE "]" .GOTO NOBRK
.IF BEG NE "[" .SETS PARAM "["+PARAM
.IF END NE "]" .SETS PARAM PARAM+"]"
SET DEFAULT 'PARAM'
.;
.; CHECK TO SEE IF DIRECTORY EXISTS.
.;
.SETS TDIR <DIRECT>
.TEST TDIR
.SETN LEN '<STRLEN>'-1
.SETS TESTD TDIR[2:LEN]
.;
.; FIRST CONVERT POSSIBLE G,M SPECIFICATION INTO GGGMMM
.;
.PARSE TESTD "," G M
.IF <STRLEN> NE 2 .GOTO C2
.TEST G
.IF <STRLEN> = 2 .SETS G "0"+G
.IF <STRLEN> = 1 .SETS G "00"+G
.TEST M
.IF <STRLEN> = 2 .SETS M "0"+M
.IF <STRLEN> = 1 .SETS M "00"+M
.SETS TESTD G+M
.;
.C2:
.TESTFILE [0,0]'TESTD'.DIR
.IF <FILERR> NE 1 .GOTO DERR
.GOTO SHOW
.;
.NOBRK:
.;
.; IF YOU HAVE ARRIVED HERE, THE PARAMETER HAS NO BRACKETS NOR DOES
.; IT CONTAIN A DEVICE SPEC.  THEREFORE, IT COULD EITHER BE REFERRING
.; TO A DIRECTORY ON THE DEFAULT DISK, OR A GLOBAL LOGICAL.  THIS PART
.; OF THIS PROCEDURE WILL TAKE CARE OF THE FOLLOWING:
.;         UIC SHULTZ, UIC 1,54, UIC SYS$LOGIN, AND UIC SHULTZ/APPL
.; IF PARAMETER CONTAINS A SLASH OR A DOLLAR SIGN, IT IS OBVIOUSLY
.; REFERRING TO A LOGICAL, IF NO SLASH OR DOLLAR SIGN, IT COULD BE
.; EITHER. FIRST LOOK FOR SLASH AND DOLLAR SIGN, IF THERE, GO TO LOGIC
.; HANDLING ROUTINE. IF NO SLASH OR DOLLAR, TRY FIRST AS DIRECTORY. IF
.; NOT VALID DIRECTORY, DO AS LOGICAL. (WHEW!)
.;
.PARSE PARAM "/" F1 F2
.IF <STRLEN> = 2 .SETS PARAM F1+"$"+F2
.IF <STRLEN> = 2 .GOTO LOGIC
.TEST PARAM "$"
.IF <STRLEN> NE  0 .GOTO LOGIC
.;
.; NO SLASH OR DOLLAR FOUND, COULD BE DIRECTORY OR LOGICAL, TEST DIR
.; FIRST.  IF NOT FOUND THEN PROCESS AS LOGICAL.
.;
SET DEFAULT ['PARAM']
.SETS TDIR <DIRECT>
.TEST TDIR
.SETN LEN '<STRLEN>'-1
.SETS TESTD TDIR[2:LEN]
.;
.; FIRST CONVERT POSSIBLE G,M SPECIFICATION INTO GGGMMM
.;
.PARSE TESTD "," G M
.IF <STRLEN> NE 2 .GOTO C3
.TEST G
.IF <STRLEN> = 2 .SETS G "0"+G
.IF <STRLEN> = 1 .SETS G "00"+G
.TEST M
.IF <STRLEN> = 2 .SETS M "0"+M
.IF <STRLEN> = 1 .SETS M "00"+M
.SETS TESTD G+M
.;
.C3:
.TESTFILE [0,0]'TESTD'.DIR
.IF <FILERR> NE 1 .GOTO LOGIC
.GOTO SHOW
.;
.LOGIC:
.;
.; OK THE DIRECTORY [<PARAM>] DOES NOT EXIST! IT MUST BE TREATED
.; AS A LOGICAL. FIRST TRY AS IS FOR SYSTEM DEFINED LOGICALS, AND
.; THEN WITH A DOLLAR APPENDED AT THE END TO CHECK FOR OURS.
.; WILL ALSO GET TO THIS POINT IF THE PARAM CONTAINED SLASH OR DOLLAR.
.; (SEE ABOVE)
.;
.TRANSLATE 'PARAM'
.SETS RSULT <EXSTRI>
.IF RSULT NE "" SET DEFAULT 'PARAM'
.IF RSULT NE "" .GOTO SHOW
.;
.; PARAM DID NOT TRANSLATE. TRY WITH APPENDING A DOLLAR SIGN.
.;
.SETS PARAM PARAM+"$"
.TRANSLATE 'PARAM'
.SETS RSULT <EXSTRI>
.IF RSULT NE "" SET DEFAULT 'PARAM'
.IF RSULT NE "" .GOTO SHOW
.;
.DERR:
.;
.; ONCE YOU GET HERE, YOU ARE S.O.L. WARN THE USER AND RESET AND SHOW
.; OLD DEFAULT.
.;
.OPEN TI:
.DATA 
.DATA UIC - Cannot set default to 'input'
.DATA       Default device and directory not changed.
.DATA 
.CLOSE TI:
SET DEFAULT 'DDIR'
.;
.SHOW:
.;
.; THIS PART OF THE CODE CLEANS UP: RESETS MCR/DCL NAMED/NONAMED AND
.; DISPLAYS THE DEFAULT DIRECTORY AS IT NOW EXISTS.
.;
.IFT MOD10 .ENABLE DECIMAL
.IFF NAMED SET DEFAULT/NONAMED
SHOW DEFAULT
.IF DEFCL = "MCR" SET TERMINAL MCR
.EXIT
