[comp.sys.handhelds] ASC to bin program

wscott@en.ecn.purdue.edu (Wayne H Scott) (12/10/90)

The following is a script that I have found useful.  It will read a
text file containing a program encoded in the ->ASC format and 
extract the binary file. 

I use this to speed downloads to my HP.  And I don't need the ->ASC program
on the 48.

It is written in perl so I realize that many people will not be able to
use it.  Someday the rest of the world will understand.

#!/usr/unsup/perl

# unasc

# A perl program to extract a HP-48 binary from a text file containing a 
# ->ASC program. 
#
# Usage: unasc file > binfile
#
# Written by Wayne Scott  1990

while (<>) {
	next if (!(/^%%HP/../"$/)); 	# Skip everything but program
	chop;				
	$file .= $_;		
}

$file =~ s/.*"(\w*)\w\w\w\w".*/\1/;	# strip newlines, ", and CRC

$file =~ s/(.)(.)/pack(C,hex(\1.\2))/eg;  # convert ascii to bin

print $file;
-- 
_______________________________________________________________________________
Wayne Scott             |  INTERNET:   wscott@ecn.purdue.edu
Electrical Engineering  |  BITNET:     wscott%ecn.purdue.edu@purccvm
Purdue University       |  UUCP:      {purdue, pur-ee}!ecn.purdue.edu!wscott