[comp.databases] Unify tools posted to comp.sources.misc

allbery@ncoast.UUCP (Brandon S. Allbery) (01/31/88)

I just sent some of my Unify tools out through comp.sources.misc.  They are:

USC -- my screen package (boy, did that bring in the mail!!!)
USP -- a preprocessor for C programs which replaces upp and does lots of other
       nifty things as well

There's more where they came from -- and a few things for Informix 3.3 as well.

USC I've posted about before; it provides screen functions upwards compatible
with the standard Unify calls, using curses so as to be able to do field
editing and some pop-up window functions, among other things.

USP is a filter which takes a C program plus USP commands as input and writes
on stdout the C program with USP commands converted to C code. USP supports
both commands and functions; functions are things like:

	$record
	$field
		These replace "upp".
	
	$(mm/dd/yy)
		Allows you to write a literal date in a more natural way,
		rather than having to convert it to the Unify internal date
		format. The input format actually uses DATETP, so European
		dates and etc. are handled automatically.
	
	$(hh:mm)
		Same thing for times.
	
	$(today)
		Expands to an expression which returns the current date at
		runtime, in Unify format.
	
	$(hour)
		Expands to an expression which returns the current date at
		runtime, in Unify format.

The most useful commands are:

$	foreach RECORD [of RECORD] [where FIELD = VALUE [and ...]]
		[by FIELD[->FIELD...][, ...]] {
		/* C code to execute on each record */
	}

Does all the work of figuring out which Unify function to use and writes all
necessary header and body code.  "of" uses explicit relationships; VALUE may
be a literal, a variable, or another field; the "by" sorts the result on the
specified fields, and allows explicit relationship chains to be followed
via the -> syntax.

$	select RECORD [of RECORD] [where FIELD = VALUE [and ...]];
$	select RECORD key VALUE;

Similar, but returns only one record.  The "of" operator figures out which
side of the explicit relationship it's on automatically and uses the correct
function.

$	get FIELD = VARIABLE;

Does a gfield(); strings are automatically null-terminated.

$	set FIELD = VARIABLE;

Does a pfield().

$	add RECORD [key VALUE];
$	add RECORD key <VALUE, VALUE...>;

Adds a record to the database; the second form constructs a COMB field value.
There is a manual page in the package, describing all functions and commands.

WARNING:  These packages are designed for use with Unify 3.2.  USC should
work with Unify 3.1, albeit with reduced functionality (in particular, the
support functions required for view mode don't exist in 3.1); USP will NOT
work under Unify 3.1.  I have no idea how either will port to Unify 4.0,
but it is certain that the new database types cannot be used with them.
-- 
	      Brandon S. Allbery, moderator of comp.sources.misc
       {well!hoptoad,uunet!hnsurg3,cbosgd,sun!mandrill}!ncoast!allbery
KABOOM!!! Worf: "I think I'm sick." LaForge: "I'm sure half the ship knows it."