1	FUNCTION INTEGER VPW_Window(CMD$)
	DECLARE INTEGER SUBPROC
	DECLARE LONG    PID
	DECLARE LONG    Istatus
	EXTERNAL INTEGER FUNCTION LIB$ATTACH
	COMMON (PID) LONG Sub_Pid
	PID = 0						! For our PID
	PID_TEXT$="        "				! length=8 for Fortran

20	IF Sub_PID = 0  THEN				!   If no window yet
	    CALL GETPID(PID_TEXT$,PID)			!     get out PID
	    Command$='$ @SYS$SYSVPWFILES:WINDOW '+pid_text$!  spawn a window
	    CALL LIB$SPAWN(Command$,,'TT:',,,Sub_pid,SUBPROC)!with return addr
	ELSE						!   Else if window exists
	    Istatus = LIB$ATTACH(Sub_PID BY REF)	!     just attach to it
	    IF Istatus = 2280			THEN	!     but if it went
	       Sub_PID=0				!     away, show it
	       GOTO 20					!     and make a new one
	    END IF					!    END IF
	END IF						! END IF
	subproc=1					! Always show success
90	VPW_Window=SUBPROC
100	FUNCTIONEND
