Commit Graph

15 Commits

Author SHA1 Message Date
Dirk Koopman
c675748ded added support for subroutines in commands
Traditionally, a command is a piece of perl that is a simple
in line lump of code e.g (blank.pl):

		my ($self, $line) = @_;
		my $lines = 1;
		my $data = ' ';
		my @f = split /\s+/, $line;
		if (@f && $f[0] !~ /^\d+$/) {
			$data = shift @f;
			$data = $data x int(($self->width-1) / length($data));
			$data .= substr $data, 0, int(($self->width-1) % length($data))
		}
		if (@f && $f[0] =~ /^\d+$/) {
			$lines = shift @f;
			$lines = 9 if $lines > 9;
			$lines = 1 if $lines < 1;
		}
		my @out;
		push @out, $data for (1..$lines);
		return (1, @out);

It is now possible to have a 'handler' and any other code you like in
a command file, for instance (again blank.pl):

sub this {}

sub that {}

sub another {}

sub handle
{
		my ($self, $line) = @_;
		my $lines = 1;
		my $data = ' ';
		my @f = split /\s+/, $line;
		if (@f && $f[0] !~ /^\d+$/) {
			$data = shift @f;
			$data = $data x int(($self->width-1) / length($data));
			$data .= substr $data, 0, int(($self->width-1) % length($data))
		}
		if (@f && $f[0] =~ /^\d+$/) {
			$lines = shift @f;
			$lines = 9 if $lines > 9;
			$lines = 1 if $lines < 1;
		}
		my @out;
		push @out, $data for (1..$lines);
		return (1, @out);
}

The 'sub handle' being the cue that distiguishes one form from the other.

The first form has the 'sub handle { <code> }' wrapped around it so, internally
they are treated the same. Each command is placed in its own DXCommandmode sub
package with a standard set of packages "use"d in front of it.

For now (at least) any functions you declare are just that. "$self" is a DXCommandmode
not a blessed reference to this command's full package name, you cannot use things like

$self->this() or $self->that()

they must be called as local functions.

This may change in the future.

Conflicts:

	perl/DXChannel.pm
	perl/Version.pm
2013-09-06 14:22:38 +01:00
Dirk Koopman
fd0a34c34a remove all $Id$ strings 2007-06-24 02:17:43 +01:00
Dirk Koopman
b9dffeff72 Prepare for git repository
remove all the versioning from the code and introduce Version.pm
fix some niffnaffs
2007-06-14 12:08:12 +01:00
minima
9b47e7023d reduce the amount of POSIX loaded.
display buddies online at logon.
2006-03-26 18:36:01 +00:00
minima
8409ae7d77 add show/grayline command from K9AN 2005-02-26 12:19:18 +00:00
minima
dbf7523a9b remove warnings from $BRANCH lines for 5.8.0 2002-07-29 15:41:49 +00:00
minima
d6ff8d0990 added new satellite stuff from Steve K9AN. Fixed upper/lower problem
in convkeps.pl.
2001-12-17 17:04:45 +00:00
minima
5a5a0fce49 added Steve K9AN's sh/moon stuff 2001-11-07 23:15:03 +00:00
minima
d0adf21cbc added Steve's (K9AN) new versions 2001-09-23 15:42:09 +00:00
minima
2b58ccdf81 change build number calculation to be more accurate 2001-09-01 12:15:09 +00:00
djk
8dfb46f118 Steve has fixed Sun.pm 2000-03-10 15:13:30 +00:00
djk
9cac314738 fixed sh/qra so that it shows the correct lat/long
tidied up satellite stuff
2000-03-08 22:16:37 +00:00
djk
589de1133c added show/satellite command 2000-01-10 13:32:37 +00:00
djk
ed104958bd new sh/sun 1999-11-19 01:06:02 +00:00
djk
0e84728de3 added show sun
allow ^Z to terminate a line
started remembering DX, WWV, ANN et al settings
1999-11-12 21:07:05 +00:00