Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!hc!beta!unm-la!unmvax!nmtsun!hydrovax From: hydrovax@nmtsun.nmt.edu (M. Warner Losh) Newsgroups: comp.os.vms Subject: Re: Getting DCL prompt within program Message-ID: <1223@nmtsun.nmt.edu> Date: 12 Jan 88 19:13:58 GMT References: <248*l_andenes@avh.unit.uninett> Organization: NMT Hydrology program Lines: 89 Summary: How to SET/GET a prompt In article <248*l_andenes@avh.unit.uninett>, l_andenes%avh.unit.uninett@TOR.NTA.NO (Leiv Arild Andenes) writes: > Hi! > I wonder if anyone out there could tell me if there exists a system > (or Run Time Library) routine to get the DCL prompt string. > I would also like to know if there is a sanktioned interface to go through. Later in this article I give a method to "get the job done". I posted a request just before Christmas, and haven't seen a single responce. Here is a small snipet of MACRO code that is a subroutine to SET the prompt. To set your prompt you need CMKRNL priv, but to read it, you don't. A brief explination of the code. It gets the address of the cli data space. This is contained in the memory location CTL$AG_CLIDATA that is defined SOMEWHERE (don't know exactly where). Then it dereferences the address with an offset of PPD$Q_CLIREG+4. This address is places into R3. This gives the PRC block for the process. Now then, the prompt is contained in two parts. The first part is it's length, that is found in PRC_B_PROMPTLEN (offset from R3). The actual text can be no longer than 30 characters (in this implementation) and is contained at the offset PRC_G_PROMPT. I know that this explination is a bit scketchy, but I stole the code from a DECUS tape a few years back (fall 1985 I think) and hacked it so I could use it for a "SD" command that was written in 'C', that intelligently set your prompt to the current directory. So I don't understand all of the implications of the code. STANDARD DISCLAIMER ABOUT VMS 5.0 : this may break when you upgrade to 5.0, as it is using structures that I couldn't find in the Orange Binders. It may not even work at all. It seems to work correctly on VMS 4.4 on a VAXstation II. There don't appear to be (at least to my eye) any trojan activity going on. If you find any, LET ME KNOW ASAP. --------------*<---------------cut here------------>*------------------ .LINK 'SYS$SYSTEM:SYS.STB'/SELECTIVE_SEARCH .LINK 'SYS$SYSTEM:DCLDEF.STB'/SELECTIVE_SEARCH .PSECT DATA RD, WRT, NOEXE, PIC, LONG ARGS: .LONG 2 .ADDRESS LEN .ADDRESS BUFF_PTR_PTR LEN: .BYTE 0 BUFF_PTR_PTR: .LONG 0 .PSECT CODE RD,NOWRT,EXE,PIC,LONG ; ; Test. A routine to attempt to set the prompt of the current process. ; LENGTH = 4 NEWPRMT = 8 .ENTRY NEW_PROMPT ^M<> MOVL LENGTH(AP), LEN MOVL NEWPRMT(AP), BUFF_PTR_PTR $CMKRNL_S ROUTIN=SET_PROMPT, ARGLST=ARGS $EXIT_S R0 RET .ENTRY SET_PROMPT ^M PUSHR #^M MOVAB G^CTL$AG_CLIDATA, R3 ; Get cli data space. MOVL PPD$Q_CLIREG+4(R3), R3 ; Get address of proc work area MOVL LENGTH(AP), R0 ; New prompt length ptr. MOVB (R0), R0 ; New prompt length. ADDB3 #3, R0, PRC_B_PROMPTLEN(R3) ; Store new prompt length. MOVL NEWPRMT(AP), R1 ; Pointer to new prompt. MOVL (R1), R1 MOVC5 R0, (R1), #32, #32, PRC_G_PROMPT(R3) ; Store new prompt. POPR #^M MOVZWL #SS$_NORMAL, R0 ; Normal exit. RET .END --------------*<---------------cut here------------>*------------------ -- bitnet: lush@nmt.csnet M. Warner Losh csnet: warner%hydrovax@nmtsun uucp: ...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!warner%hydrovax ...{cmcl2, ihnp4}!lanl!unmvax!nmtsun!hydrovax Warning: Hydrovax is both a machine, and an account, so be careful.