classes
alias is_artificial left right
alias_list is_name len substr
head is_point_process references tail
SYNTAX
obj = new StringFunctions()
DESCRIPTION
The StringFunctions class contains functions which you can apply to a strdef
. This class
exists purely for the utility of preventing pollution of name space with string operations.
EXAMPLES
objref strobj
strobj = new StringFunctions()
StringFunctions
SYNTAX
length = strobj.len(str)
DESCRIPTION
Return the length of a string.
StringFunctions
SYNTAX
index = strobj.substr(s1, s2)
DESCRIPTION
Return the index into s1 of the first occurrence of s2.
If s2 isn't a substring then the return value is -1.
StringFunctions
SYNTAX
strobj.head(str, "regexp", result)
DESCRIPTION
The result contains the head of the string
up to but not including the regexp. returns index of
last char.
StringFunctions
SYNTAX
strobj.tail(str, "regexp", result)
DESCRIPTION
The result contains the tail of the string
from the char following regexp to the end of the string.
return index of first char.
Other functions can be added as needed,
eg., index(s1, c1)
, char(s1, i)
, etc.
without polluting the global name space. In recent versions
functions can return strings.
StringFunctions
SYNTAX
strobj.right(str, n)
DESCRIPTION
Removes first n characters from str and puts the result in
str.
StringFunctions
SYNTAX
.left(str, n)
DESCRIPTION
Removes all but first n characters from str and puts the
result in str
StringFunctions
SYNTAX
.is_name(str)
DESCRIPTION
Returns 1 if the str is the name of a symbol, 0 otherwise.
This is so useful that the same thing is available with the top level
name_declared function.
StringFunctions
SYNTAX
.alias(obj, "name", &var2)
.alias(obj, "name", obj2)
.alias(obj, "name")
.alias(obj)
DESCRIPTION
"name" becomes a public variable for obj and points to the
scalar var2 or object obj2. obj.name may be used anywhere the var2 or obj2 may
be used. With no third arg, the "name" is removed from the objects
alias list. With no second arg, the objects alias list is cleared.
StringFunctions
SYNTAX
list = sf.alias_list(obj)
DESCRIPTION
Return a new List object containing String objects which contain
the alias names.
BUGS
The String class is not a built-in class. It generally gets declared when
the nrngui.hoc file is loaded and lives in stdlib.hoc.
Note that the String class must exist and its
constructor must allow a single strdef argument. Minimally:
begintemplate String
public s
strdef s
proc init() { s = $s1 }
endtemplate String
StringFunctions
SYNTAX
sf.references(object)
DESCRIPTION
Prints the number of references to the object and all objref names
that reference that object (including references via
HBox, VBox, and List). It also prints the number of references found.
StringFunctions
SYNTAX
i = sf.is_point_process(object)
DESCRIPTION
Returns 0 if the object is not a POINT_PROCESS. Otherwise
returns the point type (which is always 1 greater than the index into the
MechanismType (1) list).
StringFunctions
SYNTAX
i = sf.is_artificial(object)
DESCRIPTION
Returns 0 if the object is not an ARTIFICIAL_CELL. Otherwise
returns the point type (which is always 1 greater than the index into the
MechanismType (1)list).
neuron/general/classes/strfun.hel : May 13 2012