Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!/usr/bin/perl
# ^^^^^^^^ change this to point to perl in your system
$cmdname = $1 if ($0 =~ s/.*\/(.*)// );
#print "$cmdname\n";
#exit;
$usage = 0;
$nxtarg = 0;
$argc = 0;
while ($argc < @ARGV) {
if (substr($ARGV[$argc], 0, 1) eq "-") {
$nxtarg = 0;
if ($ARGV[$argc] eq "-h") {
$argc++;
$usage = 1;
}
else {
$usage = 1;
$argc++;
}
}
else {
if ($nxtarg == 0) {
push(@parlist, $ARGV[$argc]);
$argc++;
}
else {
$usage = 1;
$argc++;
}
}
}
if ($usage) {
print "Usage: $cmdname [equ] [bpos] [multno]\n";
print "\n";
print " -h print this help info\n";
print " equ equ pos to convert to multno\n";
print " bpos bpos to convert to multno\n";
print " multno convert from multno to equ, form XXXX (four hex digits)\n";
print " \n";
print " multno is built up as: \n";
print " 000000mm bbbiiiii for 32-pos board\n";
print " 000000mm bbbbiiii for 16-pos board\n";
print " 000000mm bbbbbiii for 8-pos board\n";
print " \n";
print " where m=magasine, b=board, i=individual\n";
exit 0;
}
sub printmult {
my $str = $_[0];
my $lim = $_[1];
my $mag = $_[2];
my $brdh = $_[3];
my $brdl = $_[4];
my $ind = $_[5];
my $multno = 0;
$multno = $mag * 256 + ($brdh * 32) + ($brdl * 8) + $ind;
printf("%-12s -> %04X\n",
$str, $multno, $mag, $brdh, $brdl, $ind);
}
sub printequ {
my $str = $_[0];
my $multno = $_[1];
my $mag = 0;
my $brdh = 0;
my $brd8 = 0;
my $ind8 = 0;
my $brd16 = 0;
my $ind16 = 0;
my $brd32 = 0;
my $ind32 = 0;
$mag = ($multno & 0x0300) / 256;
$brdh = ($multno & 0x00E0) / 32;
$brd8 = ($multno & 0x0018) / 8;
$brd16 = ($multno & 0x0010) / 8;
$brd32 = 0;
$ind8 = ($multno & 0x0007);
$ind16 = ($multno & 0x000F);
$ind32 = ($multno & 0x0001F);
printf("%04X -> ", $multno);
printf("8-pos: LIM-%d-%d%d-%02d, ", $mag, $brdh, $brd8, $ind8);
printf("16-pos: LIM-%d-%d%d-%02d, ", $mag, $brdh, $brd16, $ind16);
printf("32-pos: LIM-%d-%d%d-%02d\n", $mag, $brdh, $brd32, $ind32);
}
#--------------------------------------------------
my $str = "";
for ($cnt = 0; $cnt <= $#parlist; $cnt++) {
$str = $parlist[$cnt];
if ($str =~ /^([0-9]+)-([0-9]+)-([0-9])([0-9])-([0-9]+)/ ) { # equ 1-0-20-04
$lim = $1;
$mag = $2;
$brdh = $3;
$brdl = $4;
$ind = $5;
printmult($str, $lim, $mag, $brdh, $brdl, $ind);
}
elsif ($str =~ /^([0-9]+)-([0-9]+)-([0-9])([0-9])/ ) { # bpos 1-0-20
$lim = $1;
$mag = $2;
$brdh = $3;
$brdl = $4;
$ind = 0;
printmult($str, $lim, $mag, $brdh, $brdl, $ind);
}
elsif ($str =~ /^([0-9a-fA-F]{4})/ ) { # multno 16-bit hex
$multno = hex($1);
printequ($str, $multno);
}
else {
print "Unknown: $str\n";
}
}
exit(0);