aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/gks/gqopwk.x
blob: cf297f4587c8ac04c9ab0e1cce7c9b3d2078c914 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	"gks.h"

# GQOPWK -- Inquire number of open work stations.  From looking at how this
# procedure is called, it seems to have two functions, depending on the value
# of "n".  It returns either the number of active workstations (n=0), or the
# wkid for nth open workstation.

procedure gqopwk (n, errind, ol, wkid)

int	n			# Number of workstation to query
int	errind			# Error indicator; errind = 0 means no error
int	ol			# Returned value (number of open workstations)
int	wkid			# WKID of nth open workstation - returned

int	i, this_wkstation
include	"gks.com"

begin
	if (gk_std == NULL) {
	    # GKS not in proper state; no active workstations
	    errind = 7
	    wkid = -1
	    return
	} else
	    errind = 0

	if (n < 0 || n > NDEV) {
	    # Invalid workstation identifier
	    wkid = -1
	    errind = 502
	    return
	} else {
	    ol = 0
	    if (n == 0) {
	        # return the number of active workstations
	        do i = 1, NDEV {
		    if (gk_status[i] == ACTIVE)
		        ol = ol + 1
	        }
	    } else {
	        # Find the nth open workstation and return its wkid
	        this_wkstation = 0
	        do i = 1, NDEV {
		    if (gk_status[i] == ACTIVE) {
		        this_wkstation = this_wkstation + 1
		        if (this_wkstation == n) {
			    wkid = i
			    break
		        }
		    }
	        }
	    }
	}
end