Blame extension/rwarray.3am

Packit 575503
.TH RWARRAY 3am "Jan 15 2013" "Free Software Foundation" "GNU Awk Extension Modules"
Packit 575503
.SH NAME
Packit 575503
writea, reada \- write and read gawk arrays to/from files
Packit 575503
.SH SYNOPSIS
Packit 575503
.ft CW
Packit 575503
@load "rwarray"
Packit 575503
.sp
Packit 575503
ret = writea(file, array)
Packit 575503
.br
Packit 575503
ret = reada(file, array)
Packit 575503
.ft R
Packit 575503
.SH DESCRIPTION
Packit 575503
The
Packit 575503
.I rwarray
Packit 575503
extension adds two functions named
Packit 575503
.BR writea() .
Packit 575503
and
Packit 575503
.BR reada() ,
Packit 575503
as follows.
Packit 575503
.TP
Packit 575503
.B writea()
Packit 575503
This function takes a string argument, which is the name of the
Packit 575503
file to which dump the array, and the array itself as the second
Packit 575503
argument.
Packit 575503
.B writea()
Packit 575503
understands multidimensional arrays.
Packit 575503
It returns one on success, or zero upon failure.
Packit 575503
.TP
Packit 575503
.B reada()
Packit 575503
is the inverse of
Packit 575503
.BR writea() ;
Packit 575503
it reads the file named as its first argument, filling in
Packit 575503
the array named as the second argument. It clears the array
Packit 575503
first.
Packit 575503
Here too, the return value is one on success and zero upon failure.
Packit 575503
.SH NOTES
Packit 575503
The array created by
Packit 575503
.B reada()
Packit 575503
is identical to that written by
Packit 575503
.B writea()
Packit 575503
in the sense that the contents are the same. However, due
Packit 575503
to implementation issues, the array traversal order of the recreated
Packit 575503
array will likely be different from that of the original array.
Packit 575503
As array traversal order in AWK is by default undefined, this is
Packit 575503
not (technically) a problem.  If you need to guarantee a particular
Packit 575503
traversal order, use the array sorting features in
Packit 575503
.I gawk
Packit 575503
to do so.
Packit 575503
.PP
Packit 575503
The file contains binary data.  All integral values are written
Packit 575503
in network byte order.
Packit 575503
However, double precision floating-point values are written as
Packit 575503
native binary data.  Thus, arrays containing only string data
Packit 575503
can theoretically be dumped on systems with one byte order and
Packit 575503
restored on systems with a different one, but this has not been tried.
Packit 575503
.\" .SH BUGS
Packit 575503
.SH EXAMPLE
Packit 575503
.ft CW
Packit 575503
.nf
Packit 575503
@load "rwarray"
Packit 575503
\&...
Packit 575503
ret = writea("arraydump.bin", array)
Packit 575503
\&...
Packit 575503
ret = reada("arraydump.bin", array)
Packit 575503
.fi
Packit 575503
.ft R
Packit 575503
.SH "SEE ALSO"
Packit 575503
.IR "GAWK: Effective AWK Programming" ,
Packit 575503
.IR filefuncs (3am),
Packit 575503
.IR fnmatch (3am),
Packit 575503
.IR fork (3am),
Packit 575503
.IR inplace (3am),
Packit 575503
.IR ordchr (3am),
Packit 575503
.IR readdir (3am),
Packit 575503
.IR readfile (3am),
Packit 575503
.IR revoutput (3am),
Packit 575503
.IR time (3am).
Packit 575503
.SH AUTHOR
Packit 575503
Arnold Robbins,
Packit 575503
.BR arnold@skeeve.com .
Packit 575503
.SH COPYING PERMISSIONS
Packit 575503
Copyright \(co 2012, 2013,
Packit 575503
Free Software Foundation, Inc.
Packit 575503
.PP
Packit 575503
Permission is granted to make and distribute verbatim copies of
Packit 575503
this manual page provided the copyright notice and this permission
Packit 575503
notice are preserved on all copies.
Packit 575503
.ig
Packit 575503
Permission is granted to process this file through troff and print the
Packit 575503
results, provided the printed document carries copying permission
Packit 575503
notice identical to this one except for the removal of this paragraph
Packit 575503
(this paragraph not being relevant to the printed manual page).
Packit 575503
..
Packit 575503
.PP
Packit 575503
Permission is granted to copy and distribute modified versions of this
Packit 575503
manual page under the conditions for verbatim copying, provided that
Packit 575503
the entire resulting derived work is distributed under the terms of a
Packit 575503
permission notice identical to this one.
Packit 575503
.PP
Packit 575503
Permission is granted to copy and distribute translations of this
Packit 575503
manual page into another language, under the above conditions for
Packit 575503
modified versions, except that this permission notice may be stated in
Packit 575503
a translation approved by the Foundation.
Packit 575503
.\" vim: set filetype=nroff :