Warning
These functions are provided for legacy code support. When writing new code, consider using Python input-output equivalents.
h.getstr(strvar)
h.getstr(strvar, 1)
###########################################
### create a file titled "file.dat" with: #
### hello #
### world #
###########################################
from neuron import h, gui
def r_open(ndat):
h.ropen("file.dat")
string = ""
s = h.ref(string)
x = []
for i in range(ndat):
h.getstr(s, 1)
x.append(s[0])
h.ropen()
return x
# ndat is number of data points
ndat = 2
x = r_open(ndat)
print x
See also
Example:
from neuron import h, gui def response(answer): if (answer == 0): print "No" else: print "Yes" i = 0 while i == 0: i = h.sred("Shall we?", "y", "ny") response(i)
Suppose in response to the HOC command: print fscan(), fscan() the user types: this is a number 1.3e4 this is not45 this is 25 Then HOC will print: 13000 25
###########################################
### create a file titled "file.dat" with: #
### 42 13.7 #
### 14 64.1 #
### 12 9 #
###########################################
from neuron import h, gui
def r_open(ndat):
h.ropen("file.dat")
x = []
y = []
for i in range(ndat):
x.append(h.fscan())
y.append(h.fscan())
h.ropen()
return x, y
# ndat is number of data points
ndat = 3
x, y = r_open(ndat)
These functions are provided for legacy code support. In Python, it only supports file input not terminal input.
When writing new code, consider using Python input-output equivalents.
See also
File.scanvar(), read, File.ropen(), File(), sscanf(), StringFunctions, getstr()