aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/ranges/rginrange.x
blob: 7dd946ae4f7f8873bf29527616fb1db37b164d39 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<pkg/rg.h>

# RG_INRANGE -- Is value in the ranges?

int procedure rg_inrange (rg, rval)

pointer	rg				# Ranges
int	rval				# Range value to test

int	i

begin
	# Error check the range pointer.

	if (rg == NULL)
	    call error (0, "Range descriptor undefined")

	do i = 1, RG_NRGS(rg) {
	    if ((RG_X1(rg, i) <= RG_X2(rg, i)) && (rval >= RG_X1(rg, i)) &&
		    (rval <= RG_X2(rg, i)))
		return (YES)
	    else if ((rval >= RG_X2(rg, i)) && (rval <= RG_X1(rg, i)))
		return (YES)
	}

	return (NO)
end