Path: funic!news.funet.fi!sunic!mcsun!uunet!seismo!ukma!wuarchive!sdd.hp.com!hplabs!hplred!seroussi
From: seroussi@hplred.HP.COM (Gadiel Seroussi)
Newsgroups: comp.sys.handhelds
Subject: fmt48: a formatting/translation utility for the HP48SX
Message-ID: <6230003@hplred.HP.COM>
Date: 12 Mar 91 18:59:52 GMT
Organization: Hewlett Packard Labs, Palo Alto CA
Lines: 612

Attached to the end of the note is the uuencoded source of
a program fmt48.c (V 0.05). This is a hack I wrote several months
ago to "beautify" HP48 listings (I didn't like the format produced
when downloading programs/vars/directories from the HP48 to the PC). With
some modifications, the program now also translates HP48 listings to the
".app" format liked by PDL. Two formats are automatically recognized:
1. DIR format:
	DIR
	var1 obj1
	var2 obj2
	...
	varn objn
	END
2. "Packed" format:
	\<< 
	  'var1' obj1 SWAP STO
	  'var2' obj2 SWAP STO
	  ...
	  'varn' objn SWAP STO
	\>>
The "packed" format where the name follows the object is NOT
recognized.

The program consists of a single file, and it should compile properly under any
reasonable C compiler. 
Fmt48 does a recursive PARTIAL parsing of the HP48 user language syntax, but 
it is not perfect. The following is a list of known bugs:

1) Max single token < 9000 bytes ( > 4 default size GROBS). Will fail for huge 
GROBS, strings, etc.
2) May fail for C$ strings with embedded newlines.
3) Does not handle paths correctly when a directory is embedded in a 
non-directory object; e.g. 
       DIR
	 pgm \<< DIR a 1 END \>>
       END
4) Does not remove "SWAP STO" from "packed" files.
5) May fail for Library objects; e.g.
       DIR
	 lib   Library 1234: DUMMY LIBRARY
       END
   fails, but
       DIR
	 liblist   { Library 1234: DUMMY LIBRARY }
       END
   works.

DISCLAIMERS, WARRANTIES, GUARANTEES: the program is guaranteed to be 
bug-ridden, and to fail when you most need it. Other than that, no guarantees
or warranties, implicit or explicit.  I work for HP, but this was done on my 
free time, and the company has nothing to do with it.

WARNING: ALWAYS KEEP A COPY OF YOUR ORIGINAL FILE UNTIL YOU ARE 100% 
CONVINCED THAT FMT48 DID NOT MESS IT UP IN THE PROCESS OF FORMATTING IT.
REMEMBER: THIS IS VERSION 0.5 OF A HACK.

Usage: the following is printed when you type "fmt48 -h":

FMT48  V. 0.5

usage: fmt48 [ flags ] [ filein ] [ fileout ]

Flags:
-a     :  Format PDL `.app' file.
-t     :  Translate HP48 DIR or `packed' file to PDL `.app' file.
-n     :  Put quoted names on separate lines (for `transapp').
-d"path": Set root directory to `path'.
-T     :  Translate characters 0-31 (except 10, 13) and 127-255 to
          escape sequences \ddd.
-l<num>:  Set output line length (w/o comments) to <num> (default = 50).
-i<num>:  Set indent increment to <num> (default = 2).
-I<num>:  Set comment indent to <num> (default = 52).
-q     :  Quiet mode: do not add comments to DIR files.

Files:
filein : input file (default = stdin).
fileout: output file. Defaults:
         If filein=stdin then fileout=stdout,
	 if filein=name.ext, and -t was not specified, then fileout=name.f48,
	 if filein=name.ext, and -t was specified, then fileout=name.app.

When no translations are specified, the program just formats a downloaded
HP48 file. All input files must have been transferred with translation mode 3.


Gadiel Seroussi
