1RWARRAY(3am)               GNU Awk Extension Modules              RWARRAY(3am)
2
3
4

NAME

6       writea,  reada,  writeall, readall - write and read gawk arrays to/from
7       files
8

SYNOPSIS

10       @load "rwarray"
11
12       ret = writea(file, array)
13       ret = reada(file, array)
14       ret = writeall(file)
15       ret = readall(file)
16

DESCRIPTION

18       The  rwarray  extension  adds  functions   named   writea(),   reada(),
19       writeall(), and readall(), as follows.
20
21       writea()
22              This  function takes a string argument, which is the name of the
23              file to which dump the array, and the array itself as the second
24              argument.  writea() understands multidimensional arrays.  It re‐
25              turns one on success, or zero upon failure.
26
27       reada()
28              is the inverse of writea(); it reads the file named as its first
29              argument,  filling in the array named as the second argument. It
30              clears the array first.  Here too, the return value  is  one  on
31              success and zero upon failure.
32
33       writeall()
34              This  function takes a string argument, which is the name of the
35              file to which dump the state  of  all  variables.  Calling  this
36              function  is  completely equivalent to calling writea() with the
37              second argument equal to SYMTAB.  It returns one on success,  or
38              zero upon failure.
39
40       readall()
41              This  function takes a string argument, which is the name of the
42              file from which to read the contents  of  various  global  vari‐
43              ables.  For each variable in the file, the data is loaded unless
44              the variable already exists. If the variable already exists, the
45              data  for  that variable in the file is ignored.  It returns one
46              on success, or zero upon failure.
47

NOTES

49       The array created by reada() is identical to that written  by  writea()
50       in  the sense that the contents are the same. However, due to implemen‐
51       tation issues, the array traversal order of the  recreated  array  will
52       likely  be different from that of the original array.  As array traver‐
53       sal order in AWK is by default undefined, this is not  (technically)  a
54       problem.   If  you  need to guarantee a particular traversal order, use
55       the array sorting features in gawk to do so.
56
57       The file contains binary data.  All integral values are written in net‐
58       work  byte  order.  However, double precision floating-point values are
59       written as native binary data.  Thus,  arrays  containing  only  string
60       data can theoretically be dumped on systems with one byte order and re‐
61       stored on systems with a different one, but this has not been tried.
62

EXAMPLE

64       @load "rwarray"
65       ...
66       ret = writea("arraydump.bin", array)
67       ...
68       ret = reada("arraydump.bin", array)
69       ...
70       ret = writeall("globalstate.bin")
71       ...
72       ret = readall("globalstate.bin")
73

SEE ALSO

75       GAWK:  Effective   AWK   Programming,   filefuncs(3am),   fnmatch(3am),
76       fork(3am),   inplace(3am),  ordchr(3am),  readdir(3am),  readfile(3am),
77       revoutput(3am), time(3am).
78

AUTHOR

80       Arnold Robbins, arnold@skeeve.com.
81

COPYING PERMISSIONS

83       Copyright © 2012, 2013, 2018, 2022 Free Software Foundation, Inc.
84
85       Permission is granted to make and distribute verbatim  copies  of  this
86       manual  page  provided  the copyright notice and this permission notice
87       are preserved on all copies.
88
89       Permission is granted to copy and distribute modified versions of  this
90       manual  page  under  the conditions for verbatim copying, provided that
91       the entire resulting derived work is distributed under the terms  of  a
92       permission notice identical to this one.
93
94       Permission  is granted to copy and distribute translations of this man‐
95       ual page into another language, under the above conditions for modified
96       versions,  except that this permission notice may be stated in a trans‐
97       lation approved by the Foundation.
98
99
100
101Free Software Foundation          Mar 11 2022                     RWARRAY(3am)
Impressum