File: ropen.rst

package info (click to toggle)
neuron 8.2.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,768 kB
  • sloc: cpp: 149,571; python: 58,449; ansic: 50,329; sh: 3,510; xml: 213; pascal: 51; makefile: 35; sed: 5
file content (120 lines) | stat: -rw-r--r-- 2,603 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

.. _hoc_ropen:

Open and Write to Files (Obsolete)
----------------------------------



.. hoc:function:: ropen


    Syntax:
        ``ropen("infile")``

        ``ropen()``


    Description:
        ``Ropen()`` opens *infile* for reading.  A subsequent ``ropen()`` with no arguments 
        closes the previously opened *infile*. A file which is re-opened with 
        ``ropen(infile)`` positions the stream at the beginning of the file. 

    Example:

        .. code-block::
            none

            proc r() { 
               ropen("file.dat") 
               for (i=0; i<ndat; i=i+1) { 
                  x[i] = fscan()  y[i]=fscan() 
               } 
               ropen() 
            } 

         
         

    Diagnostics:
        This function returns 0 if the file is not successfully opened. 
         

    .. seealso::
        :ref:`read <hoc_keyword_read>`, :hoc:func:`fscan`, :hoc:func:`getstr`, :hoc:class:`File`
        

    .. warning::
        There is no way to open more than one read file at a time.  The same is 
        true for write files. 
         


----



.. hoc:function:: wopen


    Syntax:
        ``wopen("outfile)``

        ``wopen()``


    Description:
        ``Wopen`` is similar to ``ropen`` but opens a file for writing. Contents of an 
        already existing *outfile* are destroyed.  Wopened files are written to 
        with :hoc:func:`fprint`. With no argument, the previously wopened file is closed.
        Wopen returns 0 on failure to open a file. 

    Example:

        .. code-block::
            none

            proc w() { 
               wopen("file.dat") 
               for (i=0; i<ndat; i=i+1) { 
                  fprint("%g %g\n", x[i], y[i]) 
               } 
               wopen() 
            } 


    .. seealso::
        :hoc:func:`fprint`, :hoc:func:`File`


----



.. hoc:function:: xopen


    Syntax:
        ``xopen("hocfile")``

        ``xopen("hocfile", "RCSrevision")``


    Description:
        ``Xopen()`` executes the commands in ``hocfile``.  This is a convenient way 
        to define user functions and procedures. 
        An optional second argument is the RCS revision number in the form of a 
        string. The RCS file with that revision number is checked out into a 
        temporary file and executed. The temporary file is then removed.  A file 
        of the same primary name is unaffected. 


----



.. hoc:function:: fprint

        Same as :hoc:func:`printf` but prints to a file opened with :hoc:func:`wopen`. If no file
        is opened it prints to the standard output.