#!/usr/bin/perl

# $Id: status2,v 1.2 1998-04-06 01:23:53-04 dshaw Exp $

use xtend;

# This is a simple program to just print out the status of the X10 system
# You can use it as a base for your own programs.

# This is essentially the same program as perl-sample1, but it uses the
# xtend.pm library to do the tests.

# gather all of the X10_ prefixed keys
foreach $var (keys %ENV)
	{
	push(@x10,$var) if($var=~s/^X10_//);
	}

# sort the list numerically, and then alphabetically.
foreach $key (sort alpha sort numerically @x10)
	{
	print "$key is";
	print " [on]" if(&is_on($key));
	print " [addressed]" if(&is_addressed($key));
	print " [appliance]" if(&is_appliance($key));
	print "\n";
	}

print "\n";

sub numerically
	{
	# sort numerically, but leave off the initial letter (A-P)
	return substr($a,1) <=> substr($b,1);
	}

sub alpha
	{
	# sort alpha, using only the initial letter (A-P)
	return substr($a,0,1) cmp substr($b,0,1);
	}
