From: HENRY::IN%"munnari!murdu.oz!u3369429%seismo.css.gov%sri-kl.ARPA%relay.cs.net@rca.com" 17-FEB-1987 09:06 To: Subj: Re: A Useful 'SET DEFAULT' Replacement In article <8702131859.AA01619@blia.BLI> forrest@cgl.ucsf.edu@blia.UUCP (Jon Forrest) writes: >The following is a command procedure that replaces the >'SET DEFAULT' command. There have been many versions >of such command procedures, My hot favourite is "SD" by Richard L.Bryan, Stan Knutson, Vicki, Tom Kent and Alan L. Zirkle. Beats everything I've seen so far. >The primary feature of my version is that it >sets your prompt to the complete default directory name. Don't you get into difficulties if the length of your current directory string is greater than 32 characters? I use my prompt-string for two different things: A "$$ " indicates that my privileges are switched on, a "# " indicates that they are disabled. When I also wanted to include the "current directory" in my prompt, I found it very inconvenient to look for the cursor all over the screen. I like things to be predictable. So I came up with a prompt string which displays the directory on the far right, while the usual prompt ({"$$ "|"# "}) appears on the left. The resulting procedure ("PCD") is called by my version of "cd" ("SD", see above). Here it is: $ Verify='F$Verify(F$TRNLNM("COMMAND_DEBUG")) $! Procedure: PCD.COM V-1.24 Michael Bednarek November 1986 $! Sets prompt to Current Directory/CR/Previous Prompt $! It produces a 32 character prompt string with the directory as far to the $! right as possible, positioning the cursor however after the 'previous prompt' $! This can result in a strange appearance with long directory names; never $! mind, just type over it. $ CR[0,8]=13 ! Carriage Return $ TAB[0,8]=9 ! Horizontal Tab $ Old_Prompt=F$Environment("Prompt") $ pCR=F$Locate(CR,Old_Prompt) ! position of in Old_Prompt $ If pCR.eq.F$Length(Old_Prompt) then pCR=-1 $ Prompt=F$Extract(pCR+1,255,Old_Prompt) ! part of Old_Prompt after $ lP=F$Length(Prompt) ! length thereof $ Directory=F$Environment("DEFAULT") $ lD=F$Length(Directory) $ If lP+lD.le.31 then goto Do_it $! If the length of the part of OLD_Prompt that we want to retain (lP) plus $! the length of the current directory is greater than 31 we extract the $! rightmost part of the directory string. $ x=31-lP $ Directory=F$Extract(lD-30+lP,x,Directory) $ lD=x $ Do_it: n=31-lD-lP ! n indicates the number of s we can insert $ If n.lt.0 then n=0 $ If n*8+lD.gt.80 then n=(80-lD)/8 ! but don't make it fall off the screen $!Prompt=F$FAO("!''n'* ")+Directory+CR+Prompt $ Prompt=F$FAO("!''n'*''TAB'")+Directory+CR+Prompt $! $ Set Prompt="''Prompt'" $ Verify=F$Verify(Verify) u3369429@murdu.oz.au (Michael Bednarek)