| Well, here is a version of "find an existing display", adapted from
REMCHILD.COM...
$ ! FIND_DISPLAY.COM
$ ! This command file will look at all the _WSAx's that are already
$ ! defined on the system for your own. If it finds one, great - if
$ ! not, it will create one for you.
$ !
$ ! Input parameter P1 format: "node::server.screen"
$ ! defaults: 0.0
$ !
$ Set NoOn
$ FILTER = "uncomment,upcase,collapse" ! for F$EDIT()
$ MY_UIC = f$getjpi("","uic")
$ MY_PID = f$getjpi("","pid")
$ DEVICES_FILE = "SYS$SCRATCH:DEVICES_" + MY_PID + ".TMP;"
$ if P1 .eqs. ""
$ then
$ if (f$mode() .nes. "INTERACTIVE") -
.or. .not. f$getdvi("SYS$COMMAND","trm") then Exit
$ Read/Error=QUIT SYS$COMMAND P1 /Prompt="_Node? (Name of YOUR workstation) "
$ endif
$ P1 = f$edit(P1,FILTER)
$ MY_NODE = f$element(0,":",P1) - ":"
$ if MY_NODE .eqs. "" then Exit
$ MY_SERVER = f$element(2,":",P1) - ":"
$ MY_SCREEN = f$element(1,".",MY_SERVER) - "."
$ MY_SERVER = f$element(0,".",MY_SERVER) - "."
$ if MY_SERVER .eqs. "" then MY_SERVER = "0"
$ if MY_SCREEN .eqs. "" then MY_SCREEN = "0"
$ MY_DISPLAY = f$fao("!AS::!AS.!AS", MY_NODE, MY_SERVER, MY_SCREEN)
$ WILDCARD_MODE = (f$locate("*",MY_DISPLAY) .lt. f$length(MY_DISPLAY))
$ CANDIDATES = ""
$
$ Define/User SYS$OUTPUT 'DEVICES_FILE'
$ Show Device WSA
$ Open/Read/Error=QUIT DEV_LIST 'DEVICES_FILE'
$ ! search for the node 'MY_NODE' amungst the devices already created
$NEXT_DEV:
$ Read/Error=NO_MOORE_DEVS DEV_LIST DEV
$ if f$locate(":",DEV) .ge. f$length(DEV) then Goto NEXT_DEV
$ DEV = f$element(0,":",f$edit(DEV,FILTER))
$ if .not. f$getdvi(DEV,"EXISTS") .or. (f$getdvi(DEV,"ownuic") .nes. MY_UIC) then -
Goto NEXT_DEV
$! This may be the one...
$ Define/User SYS$OUTPUT NL:
$ Show Display/Symbol 'DEV'
$ if (DECW$DISPLAY_NODE .nes. MY_NODE) .and. (MY_NODE .nes. "*") then Goto NEXT_DEV
$ if (DECW$DISPLAY_SERVER .nes. MY_SERVER) .and. (MY_SERVER .nes. "*") then Goto NEXT_DEV
$ if (DECW$DISPLAY_SCREEN .nes. MY_SCREEN) .and. (MY_SCREEN .nes. "*") then Goto NEXT_DEV
$!$ if DECW$DISPLAY_TRANSPORT .nes. "DECNET" then Goto NEXT_DEV
$ CANDIDATES = DEV + "," + CANDIDATES
$ Goto NEXT_DEV
$
$NO_MOORE_DEVS:
$! Pick most recent device from candidate list
$ DEV = f$element(0,",",CANDIDATES) - ","
$ if DEV .eqs. "" then Goto CREATE_NEW_DISPLAY
$
$ Write SYS$OUTPUT "Using existing display device - ",DEV
$ if WILDCARD_MODE then Show Display 'DEV':
$ Define/Job/NoLog DECW$DISPLAY 'DEV':
$ Define/Process/NoLog DECW$DISPLAY 'DEV':
$ Goto DONE
$
$CREATE_NEW_DISPLAY:
$ if .not. WILDCARD_MODE
$ then
$ Write SYS$OUTPUT "Creating new display device for ",MY_DISPLAY
$ Set Display/Create /Node='MY_NODE' /Server='MY_SERVER' /Screen='MY_SCREEN'
$ else
$ ! Wildcard mode - Do not create new display, just report none found...
$ Write SYS$OUTPUT "Could not find any display device matching ",MY_DISPLAY," for user ",MY_UIC
$ endif
$
$DONE:
$ Show Logical DECW$DISPLAY
$
$QUIT:
$ Close/NoLog DEV_LIST
$ if f$search(DEVICES_FILE) .nes. "" then DELETE/NOLOG 'f$parse(";*",DEVICES_FILE)'
$ Exit
|
| I used to use a similar procedure to .1, but with other people gaily creating
WS devices every time they logged in, it could take rather a long time to find
mine. We ended up with hundreds of the little devils on our 8800, and that was
with relatively frequent reboots.
Eventually I changed over to only ever do a SET DISPLAY from a command
procedure, and remember what I'd done in the group logical name table. After
all, I wasn't particularly interested in typing the SET DISPLAY command anyway.
Here's the procedure; it takes one parameter, the server's nodename.
Nick.
$ transport = "DECNET"
$ if p1 .nes. "" then goto gotnode
$ p1 = f$trnlnm ("SYS$NODE")
$ transport = "LOCAL"
$gotnode:
$ if f$locate ("_", p1) .ne. f$length (p1) then -
p1 = f$extract (1, f$length (p1) - 1, p1)
$ if f$locate ("::", p1) .ne. f$length (p1) then -
p1 = f$extract (0, f$length (p1) - 2, p1)
$ user = f$edit (f$getjpi ("", "USERNAME"), "COLLAPSE")
$ lognam = "DW$''p1'_''user'"
$ if .not. f$getdvi ("''lognam'", "EXISTS") then goto create_display
$ define/nolog decw$display 'f$trnlnm (lognam)
$ goto got_display
$create_display:
$ set display/create/node='p1/transport='transport
$ define/group 'lognam 'f$trnlnm ("DECW$DISPLAY")
$got_display:
$ write sys$output "DECW$DISPLAY is ''f$trnlnm (""DECW$DISPLAY"")"
|
| RE: .1 and .2...
Yes, I've done something similar, except that I use sys$rem_node instead
of asking the user for it, and my procedure is a whole lot less chatty.
What I am aiming for is to have it be totally automagic. I do not want
to create a new display device if the remote is NOT A WORKSTATION, and I
dont want to prompt the user for ANYTHING.
I was sort of hoping that there was a f$getdvi item I could query, or
that I could open the server, or something.
Thanks for the replys though!
|
| $ !+++ CHECK_WSA_REFCNT.COM - Check reference count and kill unused displays.
$ !
$ ! New with DECwindows is a neat little device called WSA0.
$ !
$ ! The problem is that you must delete the workstation device one all channels
$ ! have been closed. This is easily accomplished by SET DISPLAY/NOPERM but if
$ ! you have herds of droidheads that don't even know what the PURGE verb does,
$ ! then this command file may be what your looking for.
$ !
$ ! Just send $19.95 before midnight tonight to...
$ !
$ show device/output=sys$scratch:s'f$getjpi("","PID")'.tmp wsa
$ open devices sys$scratch:s'f$getjpi("","PID")'.tmp
$
$ Loop: - wouldn't it really be neat if DCL had one of these????
$ !
$ ! Check to see if we have found any workstation devices. Skip WSA0.
$ !
$ read/end=exit_loop devices inline
$ name = f$element(0,":",inline)
$ if f$extract(0,3,inline) .nes. "WSA" then goto loop
$ if name .eqs. ":" then goto loop
$ if f$getdvi(name,"unit") .eq. 0 then goto loop
$ if f$getdvi(name,"refcnt") .eq. 0
$ then
$ !
$ ! We will release this device since it's not being used.
$ !
$ write sys$output "Releaseing display ''name'."
$ set display 'name'/noperm
$ else
$ write sys$output "Display ''name' still has channels assigned."
$ endif
$ goto loop
$ exit_loop:
$ close devices
$ delete sys$scratch:s'f$getjpi("","PID")'.tmp;*
$ exit
|