2 files - return a file or the maximum number of open files
10 return files, int or null
13 This function, when given the argument fnum, will use it as an
14 index into an internal table of open file and return a file value.
15 If that entry in the table is not in use, then the null value is
16 returned instead. When no args are given, the maximum number of
17 open files is returned.
19 If you overwrite a variable containing a file value or don't save the
20 result of an 'fopen', the opened file still remains open. Such 'lost'
21 files can be recovered by using the 'files' function.
23 The first 3 file entries always refer to standard input, output
24 and error respectively. (see the example below) These three
25 files are already open by the calculator and cannot be closed.
27 When calc starts up, it scans for open file descriptors above
28 stderr (2) and below MAXFILES (20). Any open descriptor found
29 is assumed to be an open file opened in an unknown mode. Calc
30 will try to read and write to this file when directed.
32 Consider the following commands shell commands:
34 echo "A line of text in the file on descriptor 5" > datafile
37 then one could do the following:
40 FILE 5 "descriptor[5]" (unknown_mode, pos 0)
42 "A line of text in the file on descriptor 5"
45 ; fd = fopen("/etc/motd", "r")
47 FILE 3 "/etc/motd" (reading, pos 0)
49 FILE 3 "/etc/motd" (reading, pos 0)
51 ; if (isnull(files(4))) print "not open"
68 errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
69 fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt
71 ## Copyright (C) 1999-2006 Landon Curt Noll
73 ## Calc is open software; you can redistribute it and/or modify it under
74 ## the terms of the version 2.1 of the GNU Lesser General Public License
75 ## as published by the Free Software Foundation.
77 ## Calc is distributed in the hope that it will be useful, but WITHOUT
78 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
79 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
80 ## Public License for more details.
82 ## A copy of version 2.1 of the GNU Lesser General Public License is
83 ## distributed with calc under the filename COPYING-LGPL. You should have
84 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
85 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
87 ## @(#) $Revision: 30.1 $
88 ## @(#) $Id: files,v 30.1 2007/03/16 11:10:42 chongo Exp $
89 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/files,v $
91 ## Under source code control: 1995/03/04 11:33:19
92 ## File existed as early as: 1995
94 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
95 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/