[comp.os.vms] Question on f$getdvi lexical function

MCGUIRE@GRIN1.BITNET ("The Sysco Kid ", McGuire,Ed) (03/29/88)

> Date:         Mon, 28 Mar 88 01:38:00 CST
> From:         ACM_CSA@SWTEXAS
> Subject:      Question on f$getdvi lexical function
>
> While trying to get the device type integer of a terminal, the syntax
> used seems to crash when a spawned subprocess exists.  Even then, it isn't
> consistent in what value it returns.
>
>$ On Control Then Exit
>$ TOP: Write sys$output F$Getdvi(F$GetJPI(F$Pid(CONTEXT),"TERMINAL"),"DEVTYPE")
>$ Goto TOP

I think you are misunderstanding what your program is actually doing.  Each
time you call F$PID(CONTEXT) the system returns the process ID of another
process on the system.  It only returns the IDs of the processes that you
have privilege to see.  Your sample output might indicate that you are logged
in on three terminals as well as having a subprocess active.

> 110                                    <- First terminal
> 110                                    <- Second terminal
> 96                                     <- Third terminal
> %SYSTEM-F, invalid logical name        <- Subprocess

The subprocess doesn't have a terminal associated with it (it uses the parent
process' terminal).  F$GETJPI returns a blank.  F$GETDVI is actually generating
the error message because the blank you're passing is not a device name or a
logical name for a device.

Also, you don't have to have an infinite loop.  F$PID(CONTEXT) returns a
null string when it's looked at all the processes you are permitted to see.
The following program should illustrate what I've said.

Ed

$top:
$
$! Get next process ID; quit if no more.
$       pid = f$pid (context)
$       if pid .eqs. "" then exit
$
$! Get the process information we want for the report.  If the process does
$! not have a terminal, report `(n/a)' for the device type.
$       prcnam = f$getjpi (pid, "prcnam")
$       terminal = f$getjpi (pid, "terminal")
$       devtype = "(n/a)"
$       if terminal .nes. "" then devtype = f$getdvi (terminal, "devtype")
$
$! Report the information.
$       write sys$output "Process name: ", prcnam
$       write sys$output "Terminal:     ", terminal
$       write sys$output "Devtype:      ", devtype
$       write sys$output ""
$
$       goto top