[Elecraft] Call sign sort application

Kevin Rock kevinrock at earthlink.net
Fri Jun 24 17:12:05 EDT 2005


Howdy,
    There has been discussion on one or another of these list of free 
software.  I have been running a couple of nets over a period of time and 
have used a suggestion from a friend of mine from Albuquerque, New 
Mexico.  Paul Thomson, K5TCU, is one of the NCS operators of Rusty's 
Raiders Net.  He showed me how he sorted his list so he could rapidly find 
call signs and the operator's names while running the net.  I have taken 
his idea and created a Perl script to convert a list of callsigns, first 
names, and state/province/country into his format.
    I took a few hours over the last few days and started working on 
schemes for me to write net reports more easily.  I'll most probably 
rewrite this in Java with a number of other apps for database management 
to assist me.  I thought there may be a little interest in some free code 
but am unsure whether many use Perl as a scripting language.  For what it 
is worth you may use this code for non-commercial purposes.  I've 
copylefted it so as long as you keep my name embedded in it somewhere you 
can hack it as you like.  Support?  Well as any good Linux programmer 
knows you put comments in the code.  That is your man page ;)
    Input and output are simple ASCII text files.  Tab delimited in either 
case.  The format can be changed by altering the push statements, the 
field statements in the sort, and the output lines.  Perl is a bit odd at 
first but makes it very easy to solve a problem rapidly.  I expect the 
Java version of this will take much longer to craft.  But then it will be 
a windowing app with menus, dialog boxes, etc.  Command line apps are very 
powerful but take a bit of getting used to if you've only been exposed to 
graphic user interfaces.  However, I started with wire wrapped boards and 
assembly language quite a long time ago.  An empty EPROM provides a great 
platform for the imagination.  I quote, "But some of us get a real thrill 
out of all-night algorithmic flagellation."  Yes indeed, writing software 
(firmware in the above quote) can be a great deal of intellectual 
exercise.  Though it is quite satisfying in the end.  This little snippet 
of code was fun as an exercise to see how this sort will work for another 
application.  Perl is great for prototyping.  If you find this code of 
value that is good.  If not you can simply delete this email.
    Good luck during FD,
       Kevin.   KD5ONS



====== rip here =========== rip here =========== rip here =========== rip 
here =========== rip here =====

# Sort Call signs into suffix order
# sort ordering from suggestion by Paul Thomson, K5TCU
# Created June 23, 2005
# Cleaned up June 24, 2005
# (copyleft) K. J. Rock
# no warranty expressed or implied

use strict;
use English;

# Input files are in ASCII text
# either tab or space delimited
# call sign, first name, state/province/country

# app sorts on suffix of call and justifies on the call number
# for easy reference during nets
# prints result to screen and to an output file

# input file is named RawCallList.txt
# output file is named SortedCallList.txt
# currently the app runs in the same folder as
# the input file
# it creates the output file in the same location.

# declarations
my $file1 = "RawCallList.txt";
my $file2 = "SortedCallList.txt";
my $i;
my $length;
my @x;
my @list;
my @prefix;
my @SList;
my @SortedList;

# Suck file into an array
open(MYFILE, "<$file1");
    @x = <MYFILE>;
close(MYFILE);

# get length of input array
$length = @x + 0;

# massage data into sort ready text
for ($i=0; $i<$length; $i++)
    {
    # split into call, name, and state fields
    @list = split " ", $x[$i];

    # fix 1 by calls
    if ($list[0] =~ m/^.[0-9]/)
       {
       $list[0] = " " . $list[0];
       }

    # split call sign into prefix and suffix
    $prefix[0] = substr($list[0], 0, 3);
    $prefix[1] = substr($list[0], 3);

    # put all the parts into an array of arrays called @SList
    push @SList, [ @prefix ];
    push @{ $SList[$i] }, $list[1], $list[2];
    }

@SortedList = sort
    {
    my @a_fields = @$a[0..$#$a];
    my @b_fields = @$b[0..$#$b];

    # Field 0 is prefix of call, 1 is suffix of call, 2 is name, and 3 is 
state
    # string sort on suffix of call
    $a_fields[1] cmp $b_fields[1]
    } @SList;

for ($i=0; $i<$length; $i++)
    {
    printf "%-10s %10s %5s\n", $SortedList[$i][0].$SortedList[$i][1], 
$SortedList[$i][2], $SortedList[$i][3];
    }

open(MYOTHERFILE, ">$file2");	  	#create file or truncate it
    for ($i=0; $i<$length; $i++)
       {
       printf MYOTHERFILE "%-10s %10s %5s\n", 
$SortedList[$i][0].$SortedList[$i][1],$SortedList[$i][2], 
$SortedList[$i][3];
       }
close(MYOTHERFILE);

====== rip here =========== rip here =========== rip here =========== rip 
here =========== rip here =====


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.1/28 - Release Date: 6/24/2005



More information about the Elecraft mailing list