Previous Next Table of Contents

25. GENESIS Command Reference

25.1 abort

Routine Name:   abort

Description:    Cleanly interrupts simulation in progress.

Usage:          abort

Example:        abort

Notes:          
See also: stop , step

25.2 abs

 Routine Name: abs

Description:    Returns absolute value of number.

Usage:          positive-number = abs any-number

                positive-number         returned as absolute value of
                                        any_number

                any-number              number (float or int) for which to
                                        compute absolute value

Example:        genesis >  echo { abs -22 }
                22

                genesis >  int x
                genesis >  float y
                genesis >  y = -33.333
                genesis >  echo { abs {y} }
                33.333000183
                genesis >  x = {abs {y}}
                genesis >  echo {x}
                33

Notes:          

25.3 acos

Routine Name:   acos

Description:    Returns angle (in radians) corresponding to given cosine.

Usage:          angle-in-radians = {acos cosine}

Example:        genesis >  echo { acos 1 }
                0

                genesis >  float degrees_per_radian = 360 / (2 * 3.1415926)
                genesis >  echo {{ acos 0.707} * degrees_per_radian}
                45.00865245

Notes:          
See also: cos

25.4 addaction

Routine Name:   addaction

Description:    Adds a named action to the action table used by element types.

Usage:          addaction name action_func
                addaction name id-number

Example:        addaction  NEWACTION  10
                addaction  K_squid_hh K_squid_hh_SET
                (see Scripts/tutorials/hhchan_K.g)

Notes:          Each object in a simulation is capable of performing one or
                more "actions".  An action can be described as an operation
                that an object performs on its data. Actions are defined
                within compiled functions which are attached to each object.
                (You can display a list of actions which an object can perform
                and the function(s) which perform using the showobject
                routine.)  For instance, objects of type compartment can
                perform the actions:

                RESTORE2  SAVE2  SET  CHECK  RESET  PROCESS  INIT  

                (The actions are actually performed by an underlying C
                function associated with the compartment element type.)

                You use the addaction routine to add the named action to the
                action table.  Actions are passed to the handler routines
                associated with each type of GENESIS object.  The handler is
                expected to perform the necessary actions when a given action
                type is passed to it by the simulator.

                For the most part this routine will only be used when adding
                new object types which require use of additional (non-default)
                actions already known to GENESIS.

                You use the addaction routine to define new actions to be used
                by elements.  There are a number of predefined actions 
                which are typically used by objects. PROCESS is one of them.
                New actions can be added in any object. Use the 'addaction'
                routine in the object definition script to inform the
                simulator of the new action. The case number assigned to new
                actions is relatively arbitrary as long as it does not
                conflict with the case numbers of other actions defined in the
                object.  (you should get a compiler error if there is a
                conflict). 

                When used as a GENESIS command, addaction is primarily used
                in the construction of extended objects.  It is also used as
                a library intialization command during the compilation of
                GENESIS libraries.
See also: object , Extended Objects, Defining New Objects and Commands ( NewObjects )

25.5 addalias

Routine Name:   addalias

Description:    Associates alternative name with existing GENESIS command.

Usage:          addalias alias-name command-name

Example:        addalias set setfield

Notes:          You may put a number of addalias statements in a file and
                use an include statement in the .simrc file to include the
                file when GENESIS is started.
See also: addescape

25.6 addclass

Command Name:   addclass

Description:    Adds a new class to list of currently recognized GENESIS
                element classes.

                Adds a new class tag to a given element.

Usage:          addclass [element] class-name

Example:        addclass /sine device

Notes:          The addclass routine adds a class tag to a given element
                identifying it as belonging to the given class.  Omitting
                the element defines a class name without assigning any
                element to the class.  (This is a deprecated usage which
                may not be supported in future releases).

                Objects can be grouped into named classes.  This
                grouping can be used to facilitate the specification of
                operations to be performed on functionally related
                elements.  See scheduling (e.g., the addtask
                routine, and Schedules) for an example of class use.

                Classes are simply used for grouping of related
                elements and do not alter the element functionality in
                any way.  Classes in GENESIS don't carry the full
                connotations of classes within a true object-oriented
                programming environment.  They are simply convenient
                ways of creating named groupings to which objects can be
                assigned.
See also: listclasses, deleteclass , showobject , Extended

25.7 addescape

Routine Name:   addescape

Description:    Adds an escape-key macro binding.

Usage:          addescape esc_sequence command-string [-execute] [-id string]

                esc_sequence            actual keystrokes (or representation)
                                        to associate with escape action

                command-string          string to insert in place when escape
                                        sequence is issued (should be in
                                        quotation marks if it contains blank
                                        spaces)

                -execute                flag to have command-string executed
                                        when escape sequence is called
                                        (this puts the field EXEC in the
                                        listescape table; if -exec is left
                                        out, default is REPLACE, i.e., insert
                                        command-string, unexecuted, in command
                                        line at point escape sequence is
                                        issued)

                -id string              label for this escape sequence, used
                                        typically to identify the escape
                                        sequence in user-understandable
                                        language

Example:        genesis >  addescape [15~ "/xproto" -id "F5"
                genesis >  le <F5>

                [line changes to:]

                genesis >  le /xproto
                /draw

                [associate command string 'echo "I am not a duck"' with key
                stroke sequence escape-a:]

                genesis >  addescape a "echo I am not a duck" -execute
                genesis >  <escape-a>
                I am not a duck

                [from escapelist.g file, included in startup:]

                addescape [A     <^P>                        -id "up arrow"
                addescape [B     <^N>                        -id "down arrow"
                addescape [C     <^F>                        -id "right arrow"
                addescape [D     <^H>                        -id "left arrow"
                addescape [1~    "execute movebol"   -exec   -id Find
                addescape [2~    <^I>                        -id "Insert Here"
                addescape [3~    <^D>                        -id Remove
                addescape [11~   stop                -exec   -id F1
                addescape [17~   "status -process"   -exec   -id F6
                addescape [18~   status              -exec   -id F7
                addescape [28~   "commands | more"   -exec   -id Help
                addescape [29~   step<CR>                    -id Do

Notes:          You use the addescape routine to create escape-key macros for
                commonly used command lines.  Here, the key is the key you
                will depress after the escape key, and command-string is the
                string which will be substituted into the SLI interpreter when
                the the escape sequence occurs.  (When the key is preceded by
                escape -- ctrl [ -- during keyboard input, the command-string
                is substituted.)

                A standard set of escape-key macros is specified during
                startup through the file escapelist.g.
See also: listescape

25.8 addfield

Routine Name:   addfield

Description:    Add an extended (user-defined) field to an element.

Usage:          addfield [element] field-name [-indirect element field]
                        [-description text]

                field-name      name of the new field to be added to element

                -indirect       make the field-name an alias for the a field
                                in another element

                -description    add a descriptive text string

Example:        addfield /cell/soma area -d "Area of the compartment"

Notes:          If you have a compartment, /soma, with a hh_channel
                /soma/hh_Na, then

                    addfield /soma Gk -indirect hh_Na Gk

                will add a field to /soma called Gk which is an alias for
                /soma/hh_na Gk.  Note that the path in the -indirect option
                is relative to the element to which you are adding the
                field.  The indirect element path can also be an absolute
                path.
See also: deletefield

25.9 addforwmsg

Routine Name:   addforwmsg

Description:    Forwards an incoming message to one element to another
                element.

Usage:          addforwmsg source-element message-number destination-element

                source-element  element from which the message will be
                                forwarded
        
                msg-number      number (index)  of message in message list
                                (messages are numbered from 0 up)

                destination-element
                                element to which the message will be forwarded

Notes:          The destination element must accept messages of the same
                name and with the same number of data slots as the message
                being forwarded.
See also: deleteforwmsg , showmsg , Extended

25.10 addglobal

Routine Name:   addglobal

Description:    Declares a global variable of the specified type, allowing the
                name of the global variable to be held in a string variable.

Usage:          addglobal type name [value]
                type must be one of int, float or str.

Example:

                genesis > str name = "foo"
                genesis > addglobal float {name} 5.55
                genesis > listglobals
                float           foo = 5.55
                str             name = "foo"
                (plus many others)

Notes:

Often it is useful to use a string variable name to hold the name of a
global variable.  For example, one may want to pass the name of a global
variable to a function that declares a global variable, or that sets or
returns its value.  However, normal GENESIS syntax for declarations and
assignments does not permit a variable name to be specified by a string
variable.   The routines addglobal, getglobal, and setglobal are designed
to overcome this limitation.

Note that if addglobal is used within a function definition, the declared
variable will nevertheless be global, and not local to the function.
See also: Variables , setglobal , getglobal , listglobals

25.11 addmsg

Routine Name:   addmsg

Description:    Establishes message links between two elements.

Usage:          addmsg source-element dest-delement msg-type [msg-fields]

Example:        addmsg  /cell/dend /cell/soma      RAXIAL Ra previous_state
                addmsg  /cell/soma /cell/dend      AXIAL  previous_state
                addmsg  /cell/soma /graphs/Vmgraph PLOT   Vm *voltage *red

Notes:          addmsg sets up communication links to pass information
                between elements.  Messages flow along message links created
                by the addmsg routine each time a simulation timestep is
                executed.

                For example, an asymmetric compartment connected to another
                asymmetric compartment needs to send both its axial
                resistance, Ra, and its membrane potential at the previous
                simulation step to the second compartment.  In order to update
                its state, it needs to receive the second compartment's
                previous membrane potential.
See also: deletemsg , showmsg , getmsg , gen3dmsg, dd3dmsg

25.12 addmsgdef

Routine Name:   addmsgdef

Description:    Adds a new message type allowing messages of that type
                to be added to the element.

Usage:          addmsgdef element message-name [message-arguments...]
                 -type message-type

                element         element for which to add the message
                                definition
        
                message-name    name of the message (the convention is
                                to use all upper case)

                messages-arguments
                                zero or more names for the data slots
                                of the message

                -type           option to set the message type number
                                explicitly
                                
Notes:          It is normally unnecessary use the -type option as
                addmsgdef assigns an unused message type number
                automatically. -type should be necessary only for
                specifying active messages.
See also: deletemsgdef , showobject , Extended

25.13 addobject

Routine Name:   addobject

Description:    Adds a new object to GENESIS defined by the fields, message,
                actions and class tags of the given element.  The element
                is removed and used as a prototype for initial field values
                of new elements created from the new object.

Usage:          addobject object-name element -author author-info
                 -description descriptive-text ...

                object-name     the new name for the object

                element         element from which to create the new object
        
                -author         Information about the author of the object

                -description    A description of the object; multiple
                                arguments to -description may be given
                                resulting in multiple lines of descriptive
                                text

Notes:          The object name must not be the same as an existing
                object.  Currently, there is no corresponding
                deleteobject command.
See also: listobjects , showobject , Extended

25.14 addtask

Routine Name:   addtask

Description:    Adds a simulation event to the simulation schedule.

Usage:          addtask function [arguments...]

                function        a compiled C function to be executed at each
                                step in the simulation phase according to its
                                order in the schedule table (almost always,
                                this fucntion will be "Simulate")

                arguments       arguments for the specified function

                [practically speaking this means:]

                addtask Simulate path -action action-name

                path            path specification of elements affected
                                (typically a wildcard path designation
                                with a CLASS-conditioned selection to
                                identify all elements of a specific type)

                action-name     action to perform on specified elements
                                (usually INIT or PROCESS; must be a valid
                                action, as determined by listactions)

Example:

        addtask  Simulate /##[CLASS=myclass]  -action PROCESS
        addtask  myfunction  myargs

        from startup/schedule.g:]

        deletetasks
        addtask Simulate /##[CLASS=buffer]      -action INIT
        addtask Simulate /##[CLASS=segment]     -action INIT
        addtask Simulate /##[CLASS=device]      -action INIT
        addtask Simulate /##[CLASS=buffer]      -action PROCESS
        addtask Simulate /##[CLASS=projection]  -action PROCESS
        addtask Simulate /##[CLASS=spiking]     -action PROCESS
        addtask Simulate /##[CLASS=gate] -action PROCESS
        addtask Simulate /##[CLASS=segment][CLASS!=membrane][CLASS!=gate]\
            [CLASS!=concentration][CLASS!=concbuffer] -action PROCESS
        addtask Simulate /##[CLASS=membrane]    -action PROCESS
        addtask Simulate /##[CLASS=hsolver]     -action PROCESS
        addtask Simulate /##[CLASS=concentration]       -action PROCESS
        addtask Simulate /##[CLASS=concbuffer]  -action PROCESS
        addtask Simulate /##[CLASS=device]      -action PROCESS
        addtask Simulate /##[CLASS=output]      -action PROCESS
        resched

Notes:          GENESIS provides a default simulation schedule that handles
                most simulation configurations (see above), but for your
                simulation you may need to specify a different order in which
                the simulator should process elements in the simulation.  You
                use addtask to enter simulation events to the simulation
                schedule.  

                You must be careful to avoid multiple references to elements
                with the same action. For instance, given a model containing
                the six elements /test[1-6], the following schedule would be
                an invalid specification since it would cause test[1] to be
                invoked twice on each simulation step.

                  addtask Simulate  /test[1]    -action PROCESS
                  addtask Simulate  /test[1-6]  -action PROCESS

                With broad path specifications, it is easy to accidentally
                include multiple reference. However, you can check for these
                occurrences by running the check routine.  In the above case,
                calling check after entering the above specifications would
                generate the following message:

                  ** Error - '/test[1]' multiply invoked
                    with action 'PROCESS'. Check task [2]

                Task [2] refers to the second addtask command. This
                command was responsible for the conflict.

                Alternately, not scheduling all enabled elements (see enable)
                for simulation is detected as an error by the check routine.
                For instance, given the model of six elements used above, you
                might define a schedule with one addtask call as follows:

                  addtask Simulate  /test[1-5]  -action PROCESS

                Running check would produce the following message:

                  * Warning - '/test[6]' is not scheduled for simulation.

                A valid schedule for this set of elements might be:

                    addtask Simulate  /test[1]  -action PROCESS
                    addtask Simulate  /test[2-6]  -action PROCESS

                or

                    addtask Simulate  /test[1-6]  -action PROCESS

See also:       <href id="Schedules">, <href id="resched">,
<href id="deletetasks">, <href id="showsched">, <href id="check">

25.15 argc

Routine Name:   argc

Description:    Returns argument count (number of arguments passed to a
                function).

Usage:          int-value = {argc}

Example:        if ({argc} > 3)
                        echo usage:  foo a b c
                        return
                end

Notes:          
See also: argc , argv , getarg , printargs

25.16 arglist

Routine Name:   arglist

Description:    Converts list of items into an argument list.

Usage:          arglist string

Example:
                genesis >  str s ="a b c d"
                genesis >  echo { getarg {arglist {s}} -arg 3}
                c

                str s
                str thingys = "foo bar baz"
                foreach s ({arglist {thingys}})
                    echo {s}
                end

Notes:          In each of these examples, a single string consisting of
                items separated by spaces has been converted into a list.
See also: argc , argv , getarg , printargs

25.17 argv

Routine Name:   argv

Description:    An array of strings containing the arguments passed to
                a function.

Usage:          argv position-number

Example:        

function echoargs
    int i
    echo "Number of arguments = "{argc}
    for(i=1;i<= {argc};i=i+1)
        echo {argv {i}}
    end
end

genesis > echoargs foo 5 1.23
Number of arguments = 3
foo
5
1.23

Notes:          As with C, indices of argv should start with 1.
See also: argc , arglist , getarg , printargs

25.18 asciidata

Routine Name:   asciidata

Description:  
    Converts a FMT1 formatted binary file (as produced by the
    disk_out object, for example) to ASCII.  Output is to stdout.

Usage: 
    asciidata file-name -time t -cell cell -gain g -old -xy -skip n -header
    One of options -cell, -time or -header must be given.

Example: (using the horiz_disk file from Scripts/orient_tut)

genesis > asciidata horiz_disk -header
FMT1
start time           = 0.000000e+00
time step            = 1.000000e-05
cellnum              = 25
data type            = 4
data size            = 4

genesis  > asciidata horiz_disk -cell 24 | more
-7.006086e-02
-7.012120e-02
.
.
-7.597300e-02
-7.596859e-02
//(provides Vm at each time step; adding -xy option gives t and Vm)

genesis > asciidata horiz_disk -time 1.e-4 -xy
0       -0.0706427
1       -0.0706427
2       -0.0706427
.
.
23      -0.0706427
24      -0.0706427
//(cell number and Vm for each of the 25 cells)
See also: disk_out

25.19 asin

Routine Name:   asin

Description:    Returns angle (in radians) corresponding to given sine.

Usage:          angle-in-radians = {asin sine}

Example:        genesis > echo {{ asin 0.5 }*(180/3.1415926)}
                30.00000135

Notes:          
See also: sin

25.20 atan

Routine Name:   atan

Description:    Returns angle (in radians) corresponding to given tangent.

Usage:          angle-in-radians = {atan tangent}

Example:        genesis >  echo { atan 0.876 }

Notes:          
See also: tan

25.21 call

Routine Name:   call

Description:    Allows an element to execute the function associated with the
                named action.

Usage:          call path action [args...] -parent -virtual

-parent         call the action on the element using the parent object
                of the current object context as the new object
                context

-virtual        call the action on the element using the element's
                object as the object context during the action.

Example:        call /form/graph RESET
                call /form/graph/plot ADDPTS {x} {y}

Notes:          The call routine allows the user to send an action to an
                element's handler routine (outside of the simulation cycle).

                An action executes in the context of a specific object which
                is either the element's object or some base object for the
                element.  The object context determines what fields,
                actions, messages and classes are known and accessibility of
                fields during execution of the action function.  Without any
                other options to call, the object context during the call is
                the element's object or the current object context if the
                element is already executing an action.  The -parent and
                -virtual options modify this.  These options are to be used
                when an action is called within the function definition of
                an action to be added with the addaction command.  They have
                no affect when used outside an action function.
See also: addaction , Extended

25.22 callfunc

Routine Name:   callfunc 

Description:    Allows you to call a function whose name is stored in a
                string variable.

Usage:          callfunc funcname ...

Example:        genesis  > str foo = "echo"
                genesis  > callfunc {foo} a b c
                a b c

Notes:          

See also:       

25.23 cd

Routine Name:   cd

Description:    Changes current working operating system directory.

Usage:          cd directory

Example:        genesis >  cd /usr/genesis/Scripts/neuron

Notes:          This is a GENESIS implementation of the operating system
                command cd, to assure that any change you make in the working
                directory is known to GENESIS.  (If you just issued a normal
                cd command directly, via "sh cd" for instance, the
                change in the current working directory would last only as
                long as the subshell created to enact the command, and future
                actions in GENESIS would not recognize a change.  The GENESIS
                implementation of cd fixes this.)
See also: sh

25.24 ce

Routine Name:   ce

Description:    Changes the current working element.

Usage:          ce element-path

                element-path    complete or relative pathname of element to
                                make current working element; can also be
                                operating-system style hierarchy
                                abbreviations, such as . (current),
                                .. (element above current)

Example:        ce /
                ce /proto
                ce output
                ce ..

                genesis >  create compartment foo
                genesis >  ce ^
                genesis >  pwe
                /foo
        
Notes:          All GENESIS elements exist in a hierarchy.  The root element
                lives at the top of the tree (designated by /) and child
                elements are created beneath the root.  You use the ce routine
                to move about the tree (much as you can use the "cd" command
                to move about the operating system file system).

                If the element-path specified in a ce call starts with a /
                then the path is assumed to be an absolute path from the root
                of the element hierarchy.  If the first character of the path
                specified is not a / then the path is assumed to be relative
                to the current working element.
See also: pwe , le , pushe , pope , stack

25.25 cellsheet

Routine Name:   cellsheet

Description:    Copies prototype cells into a 3-D sheet specified by
                coordinates in a file.

Usage:          cellsheet prototype dest filename [-orient][-curve]
                        [-randomise x y z] [-twirl theta]

                prototype       existing cell to copy to create cells in the
                                sheet (prototype is not changed by the
                                routine; all operations are done on the
                                copies)

                destination     element to become parent of all cells in sheet

                filename        file defining position and orientation of
                                cells (ascii file with 3 numbers for each
                                coordinate (cartesian only), followed by 3
                                coordinates for the normal vector to the
                                surface of the sheet at that point; this
                                vector does not have to be normalised; each
                                set of 6 numbers should be on different lines)

                -orient         reorients the cell to be normal to the local
                                region of the sheet

                -curve          distorts copies of prototype cell to follow
                                curvature of sheet of cells; the lengths (and
                                electrical properties) of the cell are not
                                changed (this option assumes that length of
                                each compartment is less than the radius of
                                curvature of the surface; also, the sampling
                                density over the cell sheet should be high
                                enough that the spacing between the points is
                                smaller than the length of each compartment;
                                does not attempt to curve compartments where
                                the angle of rotation would be less than 10
                                degrees, or more than 60)

                -randomise x y z
                                randomises the coordinates of copied cells by
                                the specified factors in x, y and z before the
                                orienting/positioning/curving steps
                                (randomisation involves finding length of each
                                compartment in each direction, scaling it by a
                                random number within the range of the
                                specified factor, and adding it to the
                                original; e.g., a factor of 1 would permit a
                                change of up to the original length of the
                                compartment; the electrical properties and
                                channel conductances in each compartment are
                                scaled according to the total length change)

                -twirl theta    rotates the finally positioned cell about its
                                normal by a random angle from 0 to theta
                                degrees

Example:

include protodefs.g // copied from Scripts/tutorials
readcell cell.p /library/cell  // use cell.p from Scripts/tutorials

plane planepoints 400e-6 400e-6 100e-6 100e-6 -normal
egg eggpoints 400e-6 400e-6 400e-6 100e-6 -normal

create neutral /planenet
create neutral /eggnet

rotcoord /library/cell {-3.1415927/2} -y  // point dendrite up along z-axis

cellsheet  /library/cell /planenet planepoints -orient
cellsheet  /library/cell /eggnet eggpoints -orient

showfield /planenet/cell[]/dend x y z

Notes:          Creates a sheet of cells by copying from a prototype, and
                placing them at 3-D positions specified by an ascii file. A
                number of options permit the cells to be oriented, conformed
                to the curvature of the surface, randomised, and rotated, in
                order to make the geometry more natural. 

                In the example above, the prototype cell had the apical
                dendrite pointing along the x-axis, so rotcoord was used to
                rotate it 90 degrees about the y-axis to point outward along
                the z-axis.  Then, cellsheet was used, first on a file
                containing points in a plane, and then on a file containing
                points distributed over the surface of an ovoid.  In both
                cases, the orient option was used to point the dendrite along
                the outward normal to the surface.

25.26 check

Routine Name:   check

Description:    Checks various aspects of simulation to catch specification
                errors.

Usage:          check

Example:        check

                genesis >  setfield /soma Rm -5000 Cm 0
                genesis >  check
                ** Error - Compartment : Invalid Rm. '/soma'
                ** Error - Compartment : Invalid Cm. '/soma'

Notes:          The check routine sends the CHECK action to the handlers for
                all enabled elements.  The CHECK action should verify the
                consistency and well being of the element and report any
                problems with it to the user.  (Each element which supports
                self-checking will be invoked with the CHECK action and report
                any problems.)

                In the example above, the CHECK action of the compartment
                checks to be sure that the Rm and Cm fields are set to
                positive values, and running a check prints an error message.
See also: addtask , setclock , enable , reset

25.27 chr

Routine Name:   chr

Description:    Returns ASCII character specified by number code.

Usage:          character = {chr ASCII-number}

Example:        genesis >  echo { chr 64 }
                @
                genesis > echo {chr 65}
                A
                genesis > echo {chr 97}
                a

Notes:          

25.28 clearerrors

Routine Name:   clearerrors

Description:    Resets error count to 0.

Usage:          clearerrors

Example:        clearerrors

Notes:          When the number of errors reaches its maximum value (default:
                10 syntax errors or 20 warnings) the current action is
                interrupted, the simulator goes back to the command line, and
                the errors are reset.  The clearerrors routine can be used to
                reset the error count before this occurs, allowing a
                simulation to continue running despite errors.
See also: maxerrors , maxwarnings

25.29 closefile

Routine Name:   closefile

Description:    Closes an ASCII file opened with the openfile routine.

Usage:          closefile filename

Example:        openfile myfile w
                writefile myfile 10 20 30
                closefile myfile

Notes:          When you open a file using openfile, you work on a copy of
                the file.  The closefile routine writes your changes back
                into the actual file and eliminates it from the list of open
                files.  (Closefile is automatically called for all opened
                files when you exit from GENESIS).
See also: openfile , listfiles , writefile

25.30 convert

Converting GENESIS 1.4 Scripts to GENESIS 2.0

What Does Convert Do?

GENESIS 2.0 includes a major revision of command format and command
option naming, script language syntax changes and changes in various
GENESIS features.  The convert program converts GENESIS 1.4 compatible
scripts to use GENESIS 2.0 syntax, commands and features.  Some
features have changed dramatically enough that an automatic conversion
to the new features is not feasible.  In these cases, convert generates
script code for compatibility libraries which support the GENESIS 1.4
features.

Some scripts can be converted and run successfully without any manual
changes to the converted scripts.  In most cases, however, some changes
to the converted scripts will be necessary.

The Conversion Process

Below is the process through which a GENESIS 1.4 script is converted
to run under GENESIS 2.0.

        1 - Use the convert program to convert scripts from 1.4 to
            2.0 syntax.

        2 - Fix any known problem areas (See, Convert Problem Areas).

        3 - Try the script out and fix any remaining problems.

Using the Convert Program

The easiest way to use convert is to create a new directory for the new
scripts, cd to the new directory and convert the files from the old
directory.  A simple shell procedure may be used to convert an entire
directory.  For example, if your 1.4 script files are in the directory
../oldscript, then the following shell commands will convert the entire
directory placing the converted scripts in the current working
directory:

  csh:
        foreach script (../oldscript/*.g)
            convert $script
        end

  sh:
        for script in (../oldscript/*.g)
            convert $script
        end

Global Script Variables

In order for convert to handle certain script expressions involving
global script variables, it must know what globals exist for a given
set of scripts.  (This is not a problem for a self contained script
where global variables are defined and used within the script.)
Often a single script file is devoted to defining and initializing
global variables and constants for a given set of scripts.

The -constants option of the convert program gives a list of script
files which define the global variables for the script set.  For
example, if the file constants.g contains global variable definitions
which are used througout a set of scripts in the ../oldscripts
directory then the following csh code would convert the scripts:

        foreach script (../oldscripts/*.g)
            convert $script -constants ../oldscripts/constants,g
        end

The -constants option will allow one or more scripts to be given.

Compatibility Libraries

Two areas of major change in GENESIS 2.0 are the Xodus GUI and support
for network modeling (e.g. GENESIS 1.4 connections).  Support for use
of these facilities in GENESIS 2.0 is provided by compatibility
libraries.

While the compatibility libraries allow faster conversion of GENESIS
1.4 scripts for use under GENESIS 2.0, these libraries will not be
aggresively supported and should be viewed as a transitional step in
converting scripts to GENESIS 2.0 facilities.  Those areas of your
scripts which use these libraries should eventually be recoded to use
the new GENESIS 2.0 features.  Assistance for recoding of these
features may be found in the new GENESIS 2.0 Reference Manual (not
available at this time).

The X1compat Library

Compatibility for GENESIS 1.4 features of Xodus is provided as a set of
scripts using GENESIS 2.0 extended objects to implement the old Xodus
objects and script functions to implement old Xodus commands.  To load
the X1compat library, include Scripts/X1compat in your SIMPATH and
include X1compat from your .simrc or your main simulation script.
Convert will not add an include statement for X1compat to your
scripts.

X1compat defines a set of old Xodus compatible objects which are named
using the prefix "x1" in place of the normal "x" prefix for Xodus
objects (e.g. xform becomes x1form, etc).  Convert will automatically
transform create statements from Xodus objects in 1.4 scripts to use
the X1compat objects.  Some support for field naming of old Xodus
objects is included in the new Xodus objects, which may allow direct
use of the new Xodus objects.  The -noX1compat convert option causes
convert not to perform the translation to X1compat objects.  This is
likely to be useful for only those scripts which use the basic Xodus
widgets (i.e. xform, xlabel, xbutton, xtoggle and xdialog).  Uses of
xdraw or xgraph are likely to require use of X1compat.

Convert and the X1compat library cannot address various issues of
layout of widgets on a form.  See, Convert Problem Areas, for more
information.

The Connection Compatibility Library

While GENESIS 1.4 connections are not a standard part of GENESIS 2.0, a
compatibility library may be compiled into GENESIS 2.0 which supports
the old connection feature.  (See, src/Makefile or Usermake for
instructions on including the library.) The library defines the
connection related objects (e.g. axon, synapses, etc) and the
connection related commands (e.g. region_connect, expweight,
radialdelay, etc) as well as connection specific commands which support
set/get/show of connections (e.g. setconn, getconn and showconn).
Access to connection fields is not supported by the GENESIS 2.0
setfield, getfield and showfield commands.

Convert will change connection related script statements as needed to
use the Connection Compatibility Library.  In particular, it will
convert uses of set, get and show on connections to use setconn, et
al.  In some cases, convert will be unable to convert these statements
(See, Convert Problem Areas).

Converting User Libraries

Objects and commands defined in user libraries (for the most part) will
not need to change to run under GENESIS 2.0.  To compile your libraries
and create a new GENESIS you will need to replace and update your
Usermake, Libmake(s), liblist and perhaps the library startup script.

Copy the Usermake and liblist files from the GENESIS 2.0 installation
directory to your local GENESIS directory renaming Usermake to
Makefile.  Add your user libraries to the Makefile and liblist files.

In each user library you must copy the Libmake from the GENESIS 2.0
installation directory into the library directory renaming it
Makefile.  Add your library specific information and files to the
Makefile.

The convert program cannot be used to convert startup scripts.  The
only changes you should need to make are to modify any GENESIS 1.4
script language features which change in 2.0 and to remove any
non-startup commands from the script.  (Startup commands are object,
addfunc, hashfunc, newclass and addaction.) Since a startup script is
usually straight line code and the typical commands in a 1.4 startup
script are the above named commands, there are normally no changes
required.  There are, however, some GENESIS 2.0 features you may want
to take advantage of in your startup scripts.  See the new GENESIS
Reference Manual section on library startup scripts for details.

Convert Problem Areas

There are a number of areas in which convert will be unable to
transform script statements or where the converted code will perform in
a less than optimal manner.  Each problem area described below must be
found and fixed manually.

Script Callbacks

Commands used as callbacks to script commands or functions are not
translated by convert.  As such, script callbacks like the following
would fail:

        create xbutton echoButton -script "echo -n this is a test"
        create xdialog vmDialog -script "set /mycompt Vm <v>"

The echoButton will result in a usage error when pressed and the
vmDialog will fail because the set command no longer exists.

Command Options in Script Variables

A command option which is passed to a command through a script variable
or as the result of a command or script function will not be
translated.  For example, if leoptions is a script string variable
holding the value "-R" (a recursive listing), then the following code
will not be converted:

        le {leoptions}

The code which sets leoptions must be found and changed.

Command Arguments That Look Like Options

All GENESIS 2.0 commands check for valid command options and complain
when an unkown option is given.  As a result, code like

        echo -notAnOption

will result in a usage error.  This will also be the case if a script
variable value looks like an option, e.g.

        str echoOption = "-notAnOption"
        echo {echoOption} // Usage error!

The usage statement can be avoided by placing whitespace before the
value, e.g.

        echo " -notAnOption"
        echo " "{echoOption}

Set/Get/Show Connections in Script Variables

Commands like

        set anElm:0 weight 10

will be correctly translated to use the setconn command.  However, code
like

        str connelm = "anElm:0"
        set {connelm} weight 10

will be translated to a setfield command.  Convert behaves similarly
with translating the get and show commands.

Script Variable/Command Name Conflicts

With all the command name changes in GENESIS 2.0, it is possible that a
script variable in a GENESIS 1.4 script may coinside with a new GENESIS
2.0 command name.  In this case, you may receive a syntax error or
unexpected result as the script variable will take precedence over the
command name.  This is may be particularly likely with the el command.

(The convert program may be updated at some future point to rename
 script variables which clash with GENESIS 2.0 command names.)

Setting Integration Methods

GENESIS 2.0 removes some of the previously existing integration methods
and renumbers some of the remaining methods.  Convert will handle the
renumbering as long as a number is given directly to the setmethod
command.  If this is not the case, convert will issue a warning and the
command will be left unaltered.  You must change the integration
numbering manually.  See setmethod.txt (or type "help setmethod" in
GENESIS) for the new numbering.

Sizing of Xodus Forms

XODUS 1 made use of an unsupported feature of MIT X11 which allowed
forms to automatically adjust their height to accomodate all the
widgets which they contain, even if the form was made too short.
Although this did not work under Openwindows, it allowed users of MIT
X11 to be somewhat sloppy in the sizing of forms when writing scripts.
This feature no longer exists in XODUS, so forms which are incorrectly
sized may not show all the widgets which they contain.  The most
convenient way to detemine the proper hgeom for the form is to properly
resize it with the mouse and then inspect the hgeom field for the value
to use in your script.

Apart from the preceeding issue, forms previously large enough to
encompass a given set of widgets may not be large enough under GENESIS
2.0, as the border widths of XODUS object have increased.

Positioning and Sizing of Widgets

Scripts which explicitly set the dimensions of a widget based on the
expected dimensional requirements of a 1.4 widget may cause text or
graphics within the widget to be clipped under 2.0.  This is due to the
additional requirements of the Motif style borders.

Likewise, widgets which are positioned using absolute coordinates on
the form based on expected default dimensions of other widgets on the
form may overlap other widgets on the form.

The only widget layouts used under GENESIS 1.4 which are likely to work
well under 2.0 are those using relative positioning.  Even if this is
the case, the form size may need to be changed (See Sizing of XODUS
Forms above).

25.31 copy

Routine Name:   copy

Description:    Copies an element (and its children, if any) from one portion
                of the element tree to another.

Usage:          copy src-element dest-element -repeat # -autoindex

                src-element     element to copy (if this element has
                                subelements, they too are copied)
                
                dst-element     location into which to copy src-element (if
                                dst-element already exists, src-element is
                                copied beneath it with original name; if
                                dst-element does not exist, copy of
                                src-element is given that name as new name)

                -repeat         is followed by an integer specifying how
                                many duplicates of src-element to make

                -autoindex      automatically assigns the first free element
                                index to the newly created element.

Example:        copy /cell1 /cell2

                // create 5 cells, cell[0-4]
                copy /library/protocell /cell[0] -repeat 5

Notes:          This routine copies an element and its children, without
                changing the original.

                Simulation messages and connections between elements within
                the copied subtree will be copied, but messages and
                connections to elements outside of the copied subtree will not
                be copied.

                After it has copied the object, the copy routine issues the
                COPY action for that element type, if any.
See also: create , createmap , move

25.32 cos

Routine Name:   cos

Description:    Returns cosine for given angle (specified in radians).

Usage:          cosine = {cos angle-in-radians}

Example:        float x
                x = {cos {3.14159/4}}

Notes:          
See also: acos

25.33 countchar

Routine Name:   countchar

Description:    Counts occurrences of specified character in string.

Usage:          number-of-occurrences = {countchar string char}

                number-of-occurrences   returned as integer indicating how
                                        many occurences of char were found
                                        in string

Example:        genesis >  echo {countchar "abcbdb" b}
                3

Notes:          

25.34 countelementlist

Routine Name:   countelementlist

Description:    Returns the number of elements in an element list.

Usage:          countelementlist path [-listname listname]

                path         path specification, which may include
                             wildcards such as [] or #  (note,
                             however, that operating-system style
                             use of * is not supported)

                listname     The listname argument tells it to look for the
                             field <listname> on the element in <path> and
                             treat that as an element list.

Example:

                genesis > echo {el /#}
                /proto /output /cell /control /data

                genesis > echo {countelementlist /#}
                5

                genesis > echo {countelementlist /##}
                19

Notes:
See also: el , Tree

25.35 cpu

Routine Name:   cpu

Description:    Displays current cumulative cpu usage for user and system time.

Usage:          cpu

Example:        genesis >  cpu
                user time used          = 3 sec  510000 usec
                system time used        = 1 sec  180000 usec

Notes:          This routine calls the getrusage operating system command to
                display user/system usage statistics.
See also: showstat

25.36 create

Routine Name:   create

Description:    Creates new element of specified element type.

Usage:          create element-type name -autoindex [object-specific-options]

                element-type    type of element; must be one of the valid
                                element types (objects) compiled into the
                                genesis executable, or an extended object
                                created with the GENESIS scripting language.

                name            element or path name where new element is to
                                be attached in the GENESIS element hierarchy;
                                if single name is given (i.e., no path
                                separators "/"), element is created on the
                                current working element [also can be indexed;
                                see below]

                -autoindex      automatically assigns the first free element
                                index to the newly created element.

                [options]       some elements can be created with additional
                                options which are specific to the object type
                                (see individual object documentation for
                                options)

Example:        create neutral /cell
                create compartment /cell/soma
                create xgraph voltage_plot

Notes:          The create routine is used to create new elements in the
                GENESIS element tree.  It generates an element of type
                "element-type" and places it in the element tree with the
                assigned name.

                The additional options which can be specified for the create
                routine depend on the element-type being created.  For
                example, elements which represent graphical widgets contain
                data fields for screen information such as the position and
                dimensions of the graphical object. This information may
                also be specified as an option in the creation of an element.

                    create compartment soma[0]
                    create compartment soma[1]
                    create compartment soma[10]
                    create compartment soma -autoindex

                In the example above, he name field of each element will be
                "soma" but the index fields will have values 0-2 and 10.
                The "-autoindex" option in the last statement creates the
                element with index 2.  Note that soma and soma[0] are
                equivalent i.e. the absence of an index implies an index of
                0 (the default).  Also note that the index is an arbitrary
                value and does not need to follow any order.
See also: listobjects , showobject , le

25.37 createmap

Routine Name:   createmap

Description:    Copies an element multiple times to form a two-dimensional
                array.

Usage:          createmap source dest Nx Ny -delta dx dy -origin x y -object

                source          path to the element that will be copied

                dest            pathname of the parent of the array of copies

                Nx,Ny           number of elements in the x and y dimensions
                                of resulting array

                dx,dy           distance between adjacent elements in the
                                array in x and y dimensions, in world or
                                actual coordinates (default: 1,1)

                x,y             position of first element of array (i.e.,
                                corner of array, in world coordinates
                                (default: 0,0)

                -object         indicates that the source is the name of
                                an object, rather than the path to an element

Example:        createmap /prototypes/cell /map 10 10
                createmap mycell  /network 3 5 -delta 0.1 0.2 -object

                [from /usr/genesis/Scripts/orient_tut/retina.g:]

                genesis > createmap /library/rec /retina/recplane \
                    {REC_NX}   {REC_NY} \
                    -delta  {REC_SEPX} {REC_SEPY}   \
                    -origin {-REC_NX * REC_SEPX / 2} {-REC_NY * REC_SEPY / 2}
                genesis > le /retina/recplane
                rec[0-99]/

Notes:          The createmap routine creates a two-dimensional array of the
                specified source element by making copies of the source
                element and assigning the copies x,y coordinates within the
                specified bounds.  The resulting array is placed under the
                specified destination path.  As with the copy command, the
                entire tree of child elements and messages is copied along
                with the source element.  When the "-object" option is
                used, the source is the name of a GENESIS object, instead of
                the path to an element tree.  This is most useful when a
                prototype cell is created as an extended object composed from
                a combination of basic objects with added fields and default
                values.

                The resulting array coordinates can be used by routines such
                as planarconnect, planarweight, and planardelay to assign
                connections, synaptic weights and propagation delays for
                simulation-oriented elements.  The coordinates can also be
                used to display the cells in a draw widget.
See also: copy , planarconnect , planarweight , planardelay , Extended

25.38 debug

Routine Name:   debug

Description:    Sets (or displays) the debug level used by some routines.

Usage:          debug [level]

                level           integer indicating debug level to use:
                                 0 = disable debug (nothing printed)
                                 1 = intermediate debug
                                 2 = intermediate debug
                                 3 = full Debug (print everything)

Example:        genesis >  debug
                debug level 0
                genesis >  debug 2
                debug level 2

Notes:          Sets the debug level used by some routines to report status
                information.  Increasing the level typically increases the
                amount of information produced. If no argument is given the
                current debug level is displayed.
See also: silent

25.39 delete

Routine Name:   delete

Description:    Deletes an element and all of its children.

Usage:          delete  element

Example:        delete /neuron

Notes:          The delete routine is used to delete elements from the GENESIS
                element hierarchy.  Deleting an element which has children
                attached to it will also delete all of the child elements.

                In the course of deleting the object, the delete routine also
                issues the DELETE action for the object before it is
                eliminated.

                When deleting interpol_structs that share tables between them
                (e.g. tabchannel, tab2Dchannel, or tabcurrent), or the cells
                or compartments containing them, you must call TABDELETE
                first, in order to deallocate the memory for the tables.
                Finally, you have to give the "reclaim" command for the memory
                to actually be freed.  Note that the tables are shared among
                all copies of the interpol_struct that are created by copy or
                readcell from a prototype.  Therefore, you shouldn't call
                TABDELETE unless you plan to delete all copies of the
                interpol_struct.
See also: create , reclaim

25.40 deleteaction

Routine Name:   deleteaction

Description:    Deletes an action from an element added by a previous
                addaction command

Usage:          deleteaction element action-name

                element         element to delete the action from
        
                action-name     name of the action to delete

Notes:          An object's built in actions are permanent and may
                not be deleted using deleteaction.
See also: addaction , listactions, Extended

25.41 deleteall

Routine Name:   deleteall

Description:    Deletes all existing elements.  [not recommended]

Usage:          deleteall -force

                -f              flag to force deletions

Example:        genesis > deleteall
                
                *** WARNING ***
                This function removes all elements from the simulation.
                If you really want to do this use 'deleteall -force'.

                usage: deleteall -force

                genesis > deleteall -f
                Simulator cleaned out.

Notes:          If no flags are specified, deleteall displays a warning
                message.

                The deleteall routine can be used to return the simulator to
                a startup state by deleting all existing elements, including
                elements which may be provided by default at startup.  If
                this is done, running the simulation scripts again could
                produce different results.

                If you really need to delete all the elements in your GENESIS
                session, you might as well quit exit from GENESIS completely
                and start again -- deleteall just deletes all the elements
                and might not reset other parameters to appropriate values.

                In general, you should not use the deleteall routine.
See also: delete

25.42 deleteclass

Routine Name:   deleteclass

Description:    Delete a class tag from an element which was previously
                added using addclass.

Usage:          deleteclass element class-name

                element         element from which to delete the class

                class-name      name of the class to delete
        
Notes:          Deleteclass will not delete classes defined for the
                built in objects.
See also: addclass , listclasses, Extended

25.43 deletefield

Routine Name:   deletefield

Description:    Deletes an extended field which has been added to an element.

Usage:          deletefield [element] field-name

Example:        genesis > addfield /soma area
                OK
                genesis > deletefield /soma area
                OK
                genesis > deletefield /soma inject
                deletefield: Cannot delete permanent field 'inject' on element '/soma'

Notes:          Only added extended field may be deleted with deletefield.
See also: addfield

25.44 deleteforwmsg

Routine Name:   deleteforwmsg

Description:    Deletes a forwarded message previously forwarded using
                addforwmsg.

Usage:          deleteforwmsg source-element message-number destination-element

                source-element  element from which the message was
                                forwarded
        
                msg-number      number (index)  of message in message list
                                (messages are numbered from 0 up)

                destination-element
                                element to which the message was forwarded

Notes:          The destination element must accept messages of the same
                name and with the same number of data slots as the message
                being forwarded.
See also: addforwmsg , showmsg , Extended

25.45 deletemsg

Routine Name:   deletemsg

Description:    Deletes a message link between two elements.

Usage:          deletemsg element msg-number -incoming -outgoing
                        -find srcelem type

                element         element receiving or sending the message

                msg-number      index of message in element message list
                                (index can be obtained with 'showmsg'
                                routine, or, in a script, with 'getmsg' used
                                with the -find option)

                srcelem         element sending the message

                type            message type (PLOT, AXIAL, VOLTAGE, etc.)

                -incoming       message to be deleted is incoming

                -outgoing       message to be deleted is outgoing

                -find           delete the first message (lowest index)
                                matching the srcelem and type

Example:        deletemsg /cell/soma 2 -incoming

                deletemsg /data/voltage -in 0 -find /cell/soma PLOT

Notes:          The deletemsg routine is used to remove messages added using
                the addmsg routine.  Deleting earlier messages will change
                the message numbers of the remaining messages.  If
                msg-number is not known for the desired message, it may be
                found by using getmsg with the -find option.

                When the -find option of deletemsg is used, the msg-number
                argument is required, but ignored, and the message must be
                an incoming one. (The -incoming and -outcoming options are
                ignored, if specified.)
See also: addmsg , showmsg , getmsg

25.46 deletemsgdef

Routine Name:   deletemsgdef

Description:    Deletes a message definition previously added to an element
                using addmsgdef.

Usage:          deletemsgdef element msg-name

                element         element from which to remove the message
                                definition
        
                msg-name        name of the message type to delete

Notes:          Deletemsgdef will not delete permanent message definitions
                defined by the built in objects.
See also: addmsgdef , showobject , Extended

25.47 deletetasks

Routine Name:   deletetasks

Description:    Removes all simulation events from the simulation schedule.

Usage:          deletetasks

Example:        deletetasks

Notes:          deletetasks removes from the simulation schedule table any
                functions currently scheduled for execution during simulation.
                This allows you to construct a new schedule using a sequence
                of addtask calls.
See also: Schedules , addtask , resched , showsched

25.48 disable

Routine Name:   disable

Description:    Disables an element and its children from participating in a
                simulation.

Usage:          disable  element

Example:        disable /prototypes/mitral_cell

Notes:          The specified elements are still accessible to basic
                operations such as setfield and showfield, but they will not
                participate in the simulation or be updated during the run of
                the simulation (i.e., when you use the step routine).

                You should run reset or resched after you disable an element
                to be sure that the simulation properly takes into account the
                disabling of the element.  (The resched command may be used to
                recompute the simulation schedule in order to remove the
                disabled element without resetting the simulation.  It is not
                a good idea to call resched frequently, especially for large
                simulations, as it does quite a bit of work.)

                The disable command cannot be used with script_out elements.
                If you need to disable a script_out element, it will be best
                to use a more versatile extended object, instead.  (See
                Extended.txt.)
See also: enable , step , reset

25.49 echo

Routine Name:   echo

Description:    Prints out its arguments to the console.

Usage:          echo [arguments] [-nonewline] [-format format-string]

                arguments       strings, or expressions enclosed in braces

                -nonewline      do not include carriage return at end of line

                format-string   a string of the form "%[flag][width]s", where
                                "width" is the minimum number of characters
                                to be output.  If the output width is less
                                than this, it is padded with blanks.  "flag"
                                is as in C; "0" means pad with zeroes, "-"
                                means left justify.  (to construct mixed
                                formats, use multiple echo commands with
                                -nonewline to place them on a single line)

Example:        
                genesis >  int five = 5
                genesis >  echo five
                five
                genesis > echo { five }
                5

                genesis > echo "Give me" -n; echo space! -f %20s
                Give me              space!

Notes:          The echo routine is used to print output to the command
                interpreter window.  If echo is followed by a string (or a
                quoted string) that string will be printed.  If echo is
                followed by a string enclosed in curly brackets, then the
                value assigned the variable named by the string will be
                printed.

25.50 egg

Routine Name:   egg

Description:    Generates coordinates for points on the surface of an ovoid.

Usage:          egg  filename  x  y  z  d  -normal

                filename        name for file into which to put generated
                                coordinates

                x, y, z         dimensions of the egg

                d               approximate distance between points

                -normal         "normal"; if selected, generates an
                                additional set of 3 coordinates per line,
                                to define the normal to the surface.  This
                                format is used by the cellsheet routine.

Example:        egg eggpoints 400e-6 400e-6 400e-6 100e-6 -normal

Notes:          Generates coordinates for points on the surface of an ovoid,
                (an egg) and puts them into a file, with an option for
                generating the normals at each point.  This is useful for
                generating layers of cells on an ovoid.  It tries to get
                fairly even spacing.  The coordinates are dumped into the
                file specified by filename with one set of coordinates per
                line.
See also: plane , cellsheet

25.51 el

Routine Name:   el

Description:    Returns list of elements matching wildcard specification.

Usage:          list-of-elements = el path [-listname listname]

                list-of-elements        returned as a text 

                path                    path specification, which may include
                                        wildcards such as [] or #  (note,
                                        however, that operating-system style
                                        use of * is not supported)

Example:        genesis >  echo {el /#}
                /proto /output  /net

                genesis >  echo {el /net/neuron[]}
                /net/neuron /net/neuron[1] /net/neuron[2] /net/neuron[3]
                
                genesis >  str name
                genesis >  foreach name ({el /# })
                ?  echo {name}
                ?  end
                /proto
                /output
                /net

Notes:          In GENESIS 1, this was EL or element_list.  getelementlist
                is an alias for el in GENESIS 2.

                The listname argument tells it to look for the field
                <listname> on the element in <path> and treat that
                as an element list.

25.52 enable

Routine Name:   enable

Description:    Enables previously disabled elements to participate in a
                simulation.

Usage:          enable  element

Example:        enable /neuron

Notes:          The enable routine is used to enable an element which has been
                disabled using the disable routine.

                You should run reset or resched after you enable a previously
                disabled element to be sure that the simulation state properly
                takes into account the newly enabled element.
See also: disable , step , reset

25.53 enddump

Routine name:   enddump

Description:    Cleans up at the end of a dumpfile. Normally
                generated by default in a dumpfile. Doesn't do much of
                anything outside a dumpfile.

Usage:          enddump

Example:        Here is a little dumpfile using initdump that recreates a
                simple 2-compartment model, and ignores the orphan element
                /x/y/z.

                ============================================================
                //genesis

                initdump -version 3 -ignoreorphans 1
                simobjdump neutral
                simobjdump compartment activation Vm previous_state \
                        Im Em Rm Cm Ra inject dia len initVm
                simundump neutral /x/y/z 0
                simundump neutral /a 0
                simundump compartment /a/compt 0 0 0.6632976405 0.6632942696 \
                        -0.3333315551 0 1 1 1 1 0 0 0
                simundump neutral /b 0
                simundump compartment /b/compt 0 0 0.3299660931 0.3299627243 \
                        0.3333349228 0 1 1 1 0 0 0 0
                addmsg /b/compt /a/compt RAXIAL Ra Vm 
                addmsg /a/compt /b/compt AXIAL Vm 
                enddump
                // End of dump

                ============================================================
Notes:          
See also: initdump , simdump , simobjdump , simundump

25.54 eof

Routine Name:   eof

Description:    Tests whether at end of currently opened file.

Usage:          eof-flag = {eof filename}

                eof-flag        returned as 1 if at end of file;
                                returned as 0 if not at end of file

                filename        name of open file to test

Example:
                str line
                openfile TestFile r
                line = {readfile TestFile -linemode}
                while (!{eof TestFile})
                    // process line from the file
                    echo {line}
                    line = {readfile TestFile -linemode}
                end

Notes:          The file must be currently open.
See also: openfile , listfiles , readfile

25.55 exists

Routine Name:   exists

Description:    Tests for existence of specified element or field.

Usage:          exists-flag = {exists element [field]}

                exists-flag     returned as 1 if element (or element field)
                                exists; returned as 0 otherwise

                element         name or full pathname of element to test

                field           element field to test existence of
                                (does not check whether field is nonempty)

Example:        if ({exists /cell/dendrite})
                        delete /cell/dendrite
                end

                genesis > create compartment soma
                genesis > echo {exists soma}
                1
                genesis > echo {exists bogus}
                0
                genesis > echo {exists soma len}
                1
                genesis > echo {exists soma bogusfield}
                0

Notes:          

25.56 exit

Routine Name:   exit

Description:    Exits from GENESIS, terminating any simulation in progress.

Usage:          exit

Notes:          You can also use "quit", which is identical to "exit".

25.57 exp

Routine Name:   exp

Description:    Returns "e" raised to specified power.

Usage:          number = {exp power}

Example:        genesis >  echo { exp 1 }
                2.718281746

Notes:          
See also: log , pow

25.58 file2tab

Routine Name:   file2tab

Description:    Utility function for loading a file into an interpol struct
                of an element

Usage:          file2tab filename element table -table2 table -table3 table
                -xy xdivs -skiplines number -calc_mode mode -autofill table

Arguments:      filename: name of ascii file to load into table.  Entries
                          must be separated by spaces, tabs or line breaks.
                          Line breaks in input file are ignored. In other
                          words, any number of numeric entries per line are
                          allowed, and all are used.

                element:  path of element containing the table
                table:    name of interpol_struct within the element.

Options:        -table2 table
                This option allows one to specify an additional table to load
                the file into. Entries are loaded alternately into the first
                table and table2. Note that table2 must be on the same
                element as table. If there are an odd number of entries in
                the file, the last one is not used.

                -table3 table
                This allows a third table. This option is similar to table2.

                -xy xdivs
                Uses xy mode for the table entries. Assumes that the points
                are stored in the file as x,y pairs. Uses the xdivs argument
                to set the table size, then figures out xmin, xmax
                and sets the table limits and dx accordingly. Uses dx 
                between all points and fills up table using linear
                interpolation if the x,y pairs in the file are not evenly
                spaced. Assumes x is monotonically increasing, behavior
                in other situations is undefined.

                -skiplines number
                Skips "number" lines at the start of the file. Useful
                for reading in 'xplot' files into a table, since these
                files usually have headers.

                -calc_mode mode
                'mode' is an integer representing one of the legal
                interpolation modes (0 = no interpolation, 1 = linear
                interpolation, 2 = fixed, see interpol doc).

                -autofill table
                table is the name of an interpol_struct in which we wish
                to place successive integers. Useful for displaying plots
                from a single series of numbers in a file:

                file2tab yvalue_file /form/graph/plot ypts -autofill xpts

                will load the numbers in yvalue_file into ypts, and put
                successive integers into xpts.

Example:        This simple example illustrates loading an xplot file into
                a table using different options to file2tab. In the first
                case we end up with the x and y values alternating. In
                the second case we end up with the y values only. In the 
                third case we use the xy mode to load the values into a linear
                table while preserving the x information.

                Datafile name is xplot.data:

                    /newplot
                    /plotname "testplot"
                    0 5
                    4 10
                    8 5
                    10 10

                script file:

                    //genesis

                    create table /tab1
                    file2tab xplot.data /tab1 table -skiplines 2
                    create table /tab2
                    file2tab xplot.data /tab2 table -table2 table -skiplines 2
                    create table /tab3
                    file2tab xplot.data /tab3 table -skiplines 2 -xy 50

                    showfield /tab1 *
                    showfield /tab2 *
                    showfield /tab3 *

-----------------------------------------------------------------------------

Notes:          The control fields of the interpol are set as follows:
                xdivs:  for 1 table:    (num_entries -1)
                        for 2 tables:   (int)(num_entries / 2 -1)
                        for 3 tables:   (int)(num_entries / 3 -1)
                xmin : 0
                xmax : 1
                calc_mode: defaults to 0 (lin-interp), but may be set on the
                        command line.
See also: tab2file , interpol_struct documentation ( Tables ), table

25.59 fileconnect

Routine Name:   fileconnect

Description:    Establishes synaptic connections and weights between groups
                of elements based on a file of weights. The routine
                sets up the connections by adding SPIKE messages between the 
                source and destination objects and then assigning a weight.

Usage:          fileconnect source_elements destination_elements \
                        filename -wtscale w

                source_elements  A wildcarded list of elements which are the 
                        sources of the SPIKE messages.  These must be of
                        class "spiking" and are usually spikegen or 
                        randomspike objects.

                destination_elements  A wildcarded list of elements which are
                        the destinations of the SPIKE messages.  These must  
                        be synchans or objects derived from synchan.

                filename        The name of an ascii file with weights
                        (as floats) separated by whitespace. Separation
                        can include spaces, line breaks etc.
                        The file is expected to have  weights for all possible
                        connections, i.e., :
                                src_nelements * dest_nelements
                        entries.
                                The order of entries is source-first. For
                        example, if the source_elements list has 9 entries
                        and the dest_elements list has 16, then the
                        first 9 entries will specify weights from each of
                        the sources to the first destination. The next 9
                        entries will be to the second destination, and so on.
                                Weights less than or equal to zero will not
                        form connections at all. 
                                Negative weights are often used to indicate
                        inhibitory input, so the command provides a way
                        around that: use a negative wtscale argument.
                        If a file has +ve as well as -ve weights,
                        it would be read twice: first with the paths of
                        excitatory receptor channels and a +ve wtscale,
                        then with the paths of the inhibitory ones and a
                        -ve wtscale.
                        
                -wtscale w      -- This specifies a scale factor for all
                        weights. As noted above, it can be negative to
                        select for inhibitory (negative) weights.
                
Example:        
                int nx = 5
                int ny = 5
                int destx = 5
                int desty = 5
                
                include cellproto.g
                
                createmap /proto/cell /lgn {nx} {ny}
                createmap /proto/cell /v1 {destx} {desty}
                fileconnect /lgn/##[TYPE=spikegen] /v1/cell[]/glu \
                        wts.file -wtscale 0.1
                fileconnect /lgn/##[TYPE=spikegen] /v1/cell[]/GABA \
                        wts.file -wtscale -0.1
                
        wts.file would have 5x5x5x5 entries. A centre-surround
        pattern for the above example could start like this:

                10 -1 0 0 0 
                -1 -1 0 0 0 
                0 0 0 0 0 
                0 0 0 0 0 
                0 0 0 0 0 

                -1 10 -1 0 0 
                -1 -1 -1 0 0 
                0 0 0 0 0 
                0 0 0 0 0 
                0 0 0 0 0 

                0 -1 10 -1 0 
                0 -1 -1 -1 0 
                0 0 0 0 0 
                0 0 0 0 0 
                0 0 0 0 0 

                ...
                
Notes:          The routine is somewhat inefficient for large input and output
                arrays with sparse connectivity, since it has to read
                Nsrc x Ndest entries. This is offset by the fact that
                the routine simultaneously creates synapses and sets
                their weights, thereby eliminating a scan for setting
                weights.  The main use is for setting up large
                networks based on weight files generated by other
                programs.  
See also: planarconnect , planarweight , planardelay ; chapter 18 of the Book of GENESIS has a lengthy discussion on these and related commands. A detailed example of the use of fileconnect is given in Scripts/examples/fileconnect.

25.60 findchar

Routine Name:   findchar

Description:    Returns location of specified character in a given string.

Usage:          position = {findchar string char}

                position        returned as integer indicating position of
                                first occurrence of char in string (positions
                                start with 0); returns -1 if char not found in
                                string

                string          string to search

                char            single character to locate in string (any
                                extra characters in char are ignored)

Example:        genesis >  echo {findchar abcbx b}
                1
                genesis > echo {findchar "a bcbx" b}
                2
                genesis > echo {findchar abcbx bx}
                1
                genesis > echo {findchar abcbx q}
                -1

Notes:
See also: strcat , strcmp , strncmp , strlen , substring

25.61 findsolvefield

Routine Name:   findsolvefield

Description:    Returns a string giving the array location of a particular
                element field value in the hines solver.  Used for
                input/output of values when the original element has been
                taken over by the hines solver and its fields may not be
                updated.

Usage:          findsolvefield hsolve element field

                hsolve      name of the hsolve element
                element     name of an element which was taken over by hsolve
                field       the field of the element whiich is to be accessed

Example:    // statements to create the hsolve element "/cell"
                ...
                setfield /cell chanmode 4
                call /cell SETUP
                ...
                create disk_out /output
                addmsg /cell /output OUTPUT \
                    {findsolvefield /cell /cell/soma/Na Gk}
                ...
                reset
or:
        genesis > echo {findsolvefield /cell /cell/soma/Na Gk}
        givals[108]
        genesis > echo {getfield /cell {findsolvefield /cell /cell/soma/Na Gk}}
        2.634178326e-10

Notes:          When using chanmodes 2 through 5 with the hines solver
                (hsolve), you can no longer assume that all the fields of the
                elements that are taken over by hsolve will be updated.  The
                findsolvefield function is used to access the hsolve arrays
                directly to output field values instead of having to use the
                old disabled elements.  This allows one to establish new
                messages for the output of field values after setup of the
                hsolve element.  The example above shows how to output the Gk
                field of the Na channel from the hsolve element /cell.  Note
                that the fields Gk, Ik, Ek, and Im are not available for
                chanmodes 2 and 3, and require the use of findsolvefield
                in chanmodes 4 and 5.
See also: hsolve

25.62 floatformat

Routine Name:   floatformat

Description:    Sets format for display of variables of type float.

Usage:          floatformat format-string

                format-string   "%[flag][width].[precision][type]",
                                indicating format to use in displaying
                                float-type variables. (default: "%0.10g")
                                The flag, width, precsion and type are
                                defined as in C, but only f and g type
                                formats are allowed.

Example:
                genesis >  float x = 3.12345678
                genesis >  echo { x }
                3.12345678
                genesis >  floatformat %0.5g
                genesis >  echo { x }
                3.1235
                genesis >  floatformat %10.5g
                genesis >  echo { x }
                    3.1235
                genesis > floatformat %10.5f
                genesis > echo { x }
                   3.12346

                genesis > float y = 1e-5
                genesis > floatformat %0.10g
                genesis > echo {y}
                1e-05
                genesis > floatformat %0.10f
                genesis > echo {y}
                0.0000100000

                genesis > floatformat %+10.2f  // show sign
                genesis > echo {x}
                     +3.12

                genesis > float pi = 3.14159265
                genesis > floatformat %-10.2f //left justify with width 10
                genesis > echo {x} {pi}
                3.12       3.14

                genesis > floatformat %010.2f  // "0" flag pads with zeroes
                genesis > echo {x} {pi}
                0000003.12 0000003.14

Notes:          As in C, the width is the minimum number of characters to be
                output.  If the output width is less than this, it is padded
                with blanks, unless the "0" flag is used.  For type f, the
                precision is the number of digits after the decimal point;
                for type g, it is the maximum number of significant digits.

25.63 flushfile

Routine Name:   flushfile

Description:    The contents of a file opened with ``openfile <filename> w''
                and written with ``writefile <filename>'' are flushed from
                the buffer onto disk. The file remains open for further
                writefile operations.

Usage:          flushfile file-name

Example:

        genesis > openfile test w
        genesis > writefile test 1.0 2.0 3.0
        genesis > more test
        genesis >
        genesis > flushfile test
        genesis > more test
        1.0 2.0 3.0
        genesis > writefile test 4.0 5.0 6.0
        genesis > more test
        1.0 2.0 3.0
        genesis > closefile test
        genesis > more test
        1.0 2.0 3.0
        4.0 5.0 6.0

Notes:          This command is useful when the contents of a file need to
                be checked before a simulation has terminated. (Writefile
                alone does not flush the buffer, and file contents are only
                available after closefile has been issued).
See also: openfile , writefile , closefile

25.64 gaussian

Routine Name:   gaussian

Description:    Returns a random value from a Gaussian (Normal) distribution.

Usage:          value = {gaussian mean standard-deviation}

Example:        genesis  > echo {gaussian 0 1 }
                0.5069125295
                genesis > echo {gaussian 0 100 }
                -63.29789352

Notes:          
See also: randseed , rand

25.65 gen2spk

Routine Name:   gen2spk

Description:    This program takes ascii files generated by GENESIS
                containing simulation times and membrane potentials
                (normally of the soma) and extracts the spike times
                relative to the onset of a current-clamp square-wave
                pulse.   The output will be a file which will have currents
                and spike times listed in the file.

Usage:          gen2spk datafile current-start current-duration \
                        total-duration -stepsize dt -maxaccuracy

Arguments:      datafile: the ascii input file.  The format of the input
                    file is as follows: The beginning of a trial is
                    indicated by the following two lines:

                        /newplot
                        /plotname 0.234

                    i.e. the plotname is the current value for that
                    trial (units are arbitrary but are usually in nA).
                    This format is taken from Matt Wilson's xplot
                    program, which is useful for displaying simulation
                    output.  The subsequent lines consist of time/Vm pairs
                    as follows:

                        0 -0.0770584
                        0.0002 -0.077233
                        etc.

                    which can be generated automatically by the
                    asc_file object of GENESIS.  Multiple trials can be
                    put in one file, as long as they're separated by the
                    /newplot, /plotname ... sequence described above.

                current-start: the time in the trace where current
                    injection begins.  Most simulations allow the cell to
                    reach equilibrium before injecting current (e.g.  for
                    50-100 msec or more).  All spike times will be relative
                    to the starting time of the current injection.  Units
                    are in seconds (SI units).

                current-duration: the duration of the current injection, in
                    seconds.

                total-duration: the total duration of the entire trace,
                    including the time before and after the current
                    injection.

Options:        -stepsize dt: the output time step i.e. the time between
                    samples in the output file.  This is usually much
                    larger than the simulation time step.  The default
                    value is 0.0001 (0.1 msec).

                -maxaccuracy:  the output spike times are printed with ten
                    digits of precision rather than 4 (the default).
                    Obviously this is only useful if your output step
                    size is small enough so that the accuracy will make
                    a difference (i.e. less than 0.0001).

Output:         A file with the same name as the input file but with
                .spk.sim added.  The file format is:

                CURR 0.1
                SPK  0.0010
                SPK  0.0123
                --------------------
                CURR 0.2
                SPK  0.0004
                SPK  0.0054
                SPK  0.0080
                ...

                etc.  CURR means the current value and is equal to the
                value in the /plotname line in the input file.  Each spike
                gets a SPK line; the value to the right of the SPK is the
                time in seconds when the spike occurred, relative to the
                start of the current injection.  Different currents are
                separated by a line of dashes.

Algorithm:      See the comments in the file src/param/gen2spk.c.

Notes:          This routine is used mainly for generating data for the
                spkcmp function for current injection simulations.
                However, it is not limited to this use and will extract
                spikes from any membrane potential waveform.

                The /newplot and /plotname lines must be written out
                explicitly to disk using writefile.  Make sure they are
                flushed to disk before starting the simulation so that they
                don't appear in the middle of what asc_file writes.  See
                the parameter search demos for examples of this.

                Some weird waveforms may defeat the spike-identifying
                algorithm.  Very small (low amplitude) spikes are a good
                example of this.  Be careful when using this routine in
                cases like this, and check the outputs with a visual
                display of the membrane potential waveform.

Example:            genesis>  gen2spk "Vmfile" 0.2 1.0 1.5

                In this case, the current comes on at 0.2 seconds, lasts
                for 1.0 seconds (i.e. until the simulation time is 1.2
                seconds) and the whole trace is 1.5 seconds long.
See also: Parameter Search ( Param ), spkcmp , shapematch

25.66 genesis

Routine Name:   genesis

Description:    Starts up the GENESIS program.  (operating system command)

Usage:          genesis [-usage][-nosimrc][-altsimrc filename][-notty][-nosig]
                        [-execdir dirname][-nice nice-level][-nox]
                        [-defaultcolor][-batch][script arg1 ...]

                -usage          print the usage message, listing options.
                -nosimrc        ignore the .simrc file
                -altsimrc       use 'filename' instead of the .simrc file
                -notty          do not accept terminal input
                -execdir        change to 'dirname' after starting genesis
                -nice           give genesis 'nice-level' priority
                -nox            start GENESIS without initializing XODUS
                -defaultcolor   use the display's default colormap
                -batch          run genesis in the background
                script          name of a GENESIS script to run

Example:        %  genesis -altsimrc ~/.backup_simrc

        Starting Genesis
   ==========================================================================
                                  G E N E S I S
                                      Release Version: 2.0

             Copyright 1988 - 1995, California Institute of Technology

    Some components are copyright by the originating institution and are used
    with the permission of the authors.
   ==========================================================================

        Executable:         /usr/genesis/genesis

        ----------------------- Starting XODUS 2.0 -----------------------

        Startup script:     ~/.backup_simrc
        SIMPATH=. /usr/home/jouser/mystartup
        SIMNOTES=/usr/home/jouser/.notes
        GENESIS_HELP=/usr/genesis/Doc
                
        genesis #0 >

Notes:  When starting, GENESIS looks for an initialization file, .simrc,
        first in the current working directory, and then in your home
        directory.  After installing genesis, this file is created in the
        GENESIS installation directory.  After making any appropriate edits,
        you should copy it to your home directory and insure that the
        genesis executable is in your path.

        A new GENESIS command line option -defaultcolor will cause GENESIS
        to use the display's default colormap, even if the default visual is
        readonly.  The net result is that colorscale colors will be shared
        among multiple GENESIS processes, but GENESIS will fail to allocate
        a colorscale if the default colortable is full.  This option may be
        used to avoid X protocol errors on some SGI systems where the X11
        server defaults to a TrueColor (24 bit) visual.

        To perform a GENESIS simulation in the background (for example if you
        want to login from home over a modem, start a simulation, and logout
        while the simulation continues to run), your simulation script should
        use no graphics, and write all output to files.

        Besides specifying the -nox option when starting genesis to avoid
        starting XODUS, you also need to use the -notty and -batch options.
        GENESIS will attempt to read from stdin after the .simrc and command
        line script are completed.  The -batch option causes genesis to exit
        rather than try to read stdin.  -notty will avoid doing any terminal
        setup and cleanup procedures which can also cause this type of
        behaviour.  You must specify both on the command line (i.e. neither
        option implies the other).  In addition, you need to redirect output
        (both stdout and stderr) to a file.  For example, to run a script
        ``batchtest.g'' and direct startup messages and any error messages to
        a log file (using the C shell) you would use:

            genesis -nox -batch -notty batchtest >& batch.log &

        With the Bourne shell (or bash) it would be:

            genesis -nox -batch -notty batchtest > batch.log 2>&1 &
See also: src/README, Simulations

25.67 getarg

Routine Name:   getarg

Description:    Returns specified item from an argument list.

Usage:          getarg [arguments] -count -arg #
                One of -count or -arg must be given

Example:        genesis >  echo {getarg 11 22 33 44 55 -arg 3}
                33
                genesis >  echo {getarg 11 22 33 44 55 -count}
                5
Notes:
See also: argc , argv , arglist , printargs

25.68 getclock

Routine Name:   getclock

Description:    Returns value of the time interval for the specified clock.

Usage:          clock-value = {getclock clock-number}

Example:        genesis >  echo { getclock 0 }
                5.000000e-05

Notes:          The getclock routine returns the current value of the step
                size for the specified clock (as a floating point number).
See also: showclocks , useclock , setclock

25.69 getdate

Routine Name:   getdate

Description:    Returns operating system date-time.

Usage:          str-value = getdate

Example:        genesis >  echo { getdate }
                Thu Jun 22 22:11:13 1995

Notes:          This is a GENESIS implementation of the operating system
                date command, to have the value returned by the routine rather
                than displayed directly to the user.  This allows the current
                date to be used as a data value within GENESIS.
See also: sh

25.70 getdefault

Routine Name:   getdefault

Description:    Returns the default value of an object field.

Usage:          getdefault object-name field-name

Example:        genesis > echo {getdefault compartment Rm}
                1

Notes:
See also: setdefault

25.71 getelementlist

Routine Name:   getelementlist

Description:    Returns list of elements matching wildcard specification.

Usage:          getelementlist path -listname listname

Notes:          This is an alias for el.

See also: el

25.72 getenv

Routine Name:   getenv

Description:    Returns value of operating-system environmental variable.

Usage:          str-value = {getenv environment-variable}

Example:        genesis >  echo { getenv DISPLAY }
                babel.bbb.edu:0

Notes:          This is a GENESIS implementation of the operating system
                printenv command, to have the value returned by the routine
                rather than displayed directly to the user.  (GENESIS also
                includes a version of printenv to have the value displayed
                directly to the user.)  The getenv routine allows the value of
                the particular operating system environmental variables to be
                used as a data value within GENESIS.
See also: setenv , printenv

25.73 getfield

Routine Name:   getfield

Description:    Returns value of field in data structure of specified element.

Usage:          getfield [pathname] field

                field-value = {getfield pathname field}

                pathname        path specification
                                defaults to current working element

                field           name of field in element data structure
                
Example:        echo {getfield /cell/soma Vm}
                setfield /cell/soma Rm {getfield /form/Rm_dialog value}

Notes:          The getfield routine returns the value of fields in the
                specified path.
See also: setfield , showfield , getfieldnames

25.74 getfieldnames

Routine Name:   getfieldnames

Description:    Returns names of all existing fields in specified element.

Usage:          element-fields = {getfieldnames Element}

                element-fields          returned as a single line (i.e., a
                                        string without carriage returns)
                                        listing fields of specified element

Example:        echo { getfieldnames /output }

                str name
                foreach name ( {getfieldnames soma })
                echo {name}
                end

Notes:          
See also: getfield , showfield , setfield

25.75 getglobal

Routine Name:   getglobal

Description:    Returns the value of a global variable, allowing the name of
                the global variable to be held in a string variable.

Usage:          getglobal name

Example:

                genesis >  str variable = "EREST"
                genesis >  addglobal float {variable}
                genesis >  setglobal {variable} -0.07
                genesis >  echo {variable} = {getglobal {variable}}
                EREST = -0.070000

Notes:

Often it is useful to use a string variable name to hold the name of a
global variable.  For example, one may want to pass the name of a global
variable to a function that declares a global variable, or that sets or
returns its value.  However, normal GENESIS syntax for declarations and
assignments does not permit a variable name to be specified by a string
variable.   The routines addglobal, getglobal, and setglobal are designed
to overcome this limitation.
See also: Variables , addglobal , setglobal , listglobals

25.76 getmsg

Routine Name:   getmsg

Description:    Returns information about a message into or out of element.

Usage:          getmsg element -incoming -outgoing -slot msg-number slot-number
                 -count -type msg-number -destination msg-number
                 -source msg-number -find srcelem type

                [One of -slot, -count, -type, -destination, -source or -find
                must be given]

                element         element for which to determine information
        
                msg-number      number (index)  of message in message list
                                (messages are numbered from 0 up)

                srcelem         element sending the message

                type            message type (PLOT, AXIAL, VOLTAGE, etc.)

                -incoming       look for an incoming message

                -outgoing       look for an outgoing message

                -slot           return the slot value for the given message
                                and slot numbers

                -count          return the number of messages in or out
                                of this element

                -type           return the message type for the message
                                having the index msg-number

                -destination    return the destination element for the
                                message having the index msg-number
                                
                -source         return the source element for the
                                message having the index msg-number

                -find           return the index (msg-number) of the first
                                message matching the srcelem and type

Example:        

        genesis > echo { getmsg /cell/dend1 -out -destination 0}
        /cell/soma
        
        genesis > echo { getmsg /cell/dend1 -out -source 0}
        /cell/dend1

        genesis > echo { getmsg /cell/dend1 -out -count }
        5

        genesis > echo { getmsg /cell/dend1  -in -destination 1 }
        /cell/dend1

        genesis > echo {getmsg /cell/soma -in -find /cell/dend1 RAXIAL}
        2

        genesis >  echo {getmsg /cell/soma  -in -type 2}
        RAXIAL

        genesis >  echo {getmsg /cell/soma  -in -slot 2 0}
        -0.07

Notes:          The -find option may only be used to find the index of
                an incoming message.  It returns -1 if there is no message
                from the specified source element and message type.

                The -count option may be useful if you want to loop over the
                index in order to find multiple messages which meet some
                specification.
See also: addmsg , deletemsg , showmsg

25.77 getparamGA

Routine Name:   getparamGA

Description:    gets the value of a parameter in a paramtableGA object as a
                floating-point number.

Usage:          getparamGA path table param

                path:   The location of the paramtableGA object in the
                        element hierarchy.

                table:  The parameter table to be accessed.

                param:  The location of the desired parameter in the
                        table.

Return value:   a float, representing the parameter value desired.

Example:            float val
                    val = {getparamGA /GA 10 1}

                This returns the second parameter (zero-indexed) from
                the tenth parameter table in the paramtableGA object
                called /GA.  The value is stored in the
                variable val.

Notes:          The reason for having this routine and setparamGA is that
                the parameter table array in paramtableGA objects is in an
                object-specific binary form (optimized for the genetic
                algorithm method) and thus can't be viewed or set directly
                using the showfield, getfield or setfield commands (at
                least not meaningfully).

                This routine and setparamGA are hacks; ultimately they should
                be made obsolete by overloading the SET and SHOW actions of
                the paramtableGA object.
See also: Parameter Search ( Param ), paramtableGA , setparamGA

25.78 getpath

Routine Name:   getpath

Description:    Returns subpart of full element pathname.

Usage:          head-string = {getpath name -head}
                tail-string = {getpath name -tail}

                head-string     full path leading to element, without actual
                                element name

                tail-string     only actual element name, without full path

                name            an element pathname

Example:        genesis > echo {getpath /cell/soma/Na_channel -head}
                /cell/soma/
                genesis >  echo {getpath /cell/soma/Na_channel -tail}
                Na_channel

Notes:          You use getpath to extract the parent or head of a path.
See also: el , pwe , stack

25.79 getsolvechildname

Routine Name:   getsolvechildname

Description:    Returns the name of the child stored at the index value
                inside the hines solver.

Usage:          getsolvechildname hsolve_element index

Example:
                genesis > showfield /cell/solve nchildren
                [ /cell/solve ]
                nchildren            = 2

                genesis > echo {getsolvechildname /cell/solve 1}
                /cell/soma/K_mit_tchan
                genesis > echo {getsolvechildname /cell/solve 2}
                /cell/soma/Na_mit_tchan

Notes:          Mainly used for debugging.
See also: hsolve , getsolvecompname , findsolvefield

25.80 getsolvecompname

Routine Name:   getsolvecompname

Description:    Returns the name of the compartment stored at the index value
                inside the hines solver.

Usage:          getsolvecompname hsolve_element index

Example:
                genesis > showfield /cell/solve ncompts
                [ /cell/solve ]
                ncompts              = 1

                genesis > echo {getsolvecompname /cell/solve 0}
                soma[0]

Notes:          Mainly used for debugging.
See also: hsolve , getsolvechildname , findsolvefield

25.81 getstat

Routine Name:   getstat

Description:    Returns current simulation time, step number, or memory used

Usage:          getstat -time -step -memory

Example:

genesis > echo {getstat -time}
0.1000500023

genesis > echo {getstat -step}
2001

genesis > {getstat -memory}
3704068

Notes:
See also: showstat

25.82 getsyncount

Routine Name:   getsyncount

Description:    This function is used to count SPIKE messages coming from a
                particular presynaptic element and/or synapses on a
                particular postsynaptic element.  If both the presynaptic
                and postsynaptic elements are specified this function
                returns the number of connections between the two i.e. the
                number of SPIKE messages from the presynaptic element which
                are sent to the given postsynaptic element.  This function
                is often used inside a loop to set fields in synapses
                between specific elements to particular values.

Usage:          getsyncount [presynaptic-element] [postsynaptic-element]

                presynaptic-element  The element sending SPIKE messages to
                        postsynaptic targets.

                postsynaptic-element  The synchan or derived element which 
                        receives SPIKE messages.

Example:        // Set the weights of all synapses that receive SPIKE messages 
                // from a given source to 10.0

                int i
                str dest
                int nsyn = {getsyncount /input[0]/spike}
                for (i = 0; i = {nsyn}; i = i + 1)
                    dest  = {getsyndest /input[0]/spike {i}}
                    index = {getsyndest /input[0]/spike {i} -index}
                    setfield {dest} synapse[{index}].weight 10.0
                end

Notes:          Synchans have an "nsynapses" field which holds a count of the
                number of synapses on a given element; this can be used instead
                of getsyncount when getting synapse counts for postsynaptic 
                elements.  
See also: getsynindex , getsynsrc , getsyndest , BoG chapter 18

25.83 getsyndest

Routine Name:   getsyndest

Description:    Returns a string which is the path of the postsynaptic
                element which receives the nth SPIKE message sent by the
                given presynaptic element.  Can also return the index of
                the synapse on this element.

Usage:          getsyndest presynaptic-element spikemsg-number -index

                presynaptic-element  The element sending SPIKE messages to
                        postsynaptic targets.

                spikemsg-number The number of the SPIKE message whose
                        destination we want.  This can be obtained by getmsg
                        or showmsg.

                -index This option returns the index of the synapse which
                        receives the SPIKE message on the destination
                        element.

Example:        str dest  = {getsyndest input[0]/spike 0}
                int index = {getsyndest input[0]/spike 0 -index}
                setfield {dest} synapse[{index}].weight 10.0

Notes:          getsynindex can also be used to get the index of a synapse
                if you know the names of the pre- and postsynaptic elements.
See also: getsyncount , getsynindex , getsynsrc , BoG chapter 18

25.84 getsynindex

Routine Name:   getsynindex

Description:    getsynindex is used to find the index of synapses between
                particular presynaptic and postsynaptic elements.  

Usage:          getsynindex presynaptic-element postsynaptic-element
                        [-number n]

                presynaptic-element  The element sending SPIKE messages to
                        postsynaptic targets.

                postsynaptic-element The synchan or derived element
                       receiving the SPIKE message from the presynaptic
                       element.

                -number n  If there is more than one synapse between the
                           given pre- and postsynaptic elements, this option
                           will return the index of the nth such synapse.
                           This option will rarely be necessary, since
                           usually there is at most one synapse between a
                           given presynaptic and postsynaptic element.  

Example:        int index = {getsynindex /input[0]/spike /cell/soma/Ex_channel}
                if (index >= 0)
                    setfield /cell/soma/Ex_channel synapse[{index}].weight 10.0
                end

Notes:          If the desired synapse does not exist a value of -1 is
                returned.
See also: getsyncount , getsynsrc , getsyndest , BoG chapter 18

25.85 getsynsrc

Routine Name:   getsynsrc

Description:    Returns a string which is the path of the presynaptic
                element sending the SPIKE message to the synapse of the
                postsynaptic element with the given index.

Usage:          getsynsrc postsynaptic-element index

                postsynaptic-element The synchan or derived element
                       receiving the SPIKE message from the source element.

                index  The index of the synapse on a synchan or derived element
                       whose source you want.

Example:        str src = {getsynsrc /cell/soma/Ex_chan 0}
                if (src == "input[0]/spike")
                    setfield /cell/soma/Ex_chan synapse[0].weight 10.0
                else
                    setfield /cell/soma/Ex_chan synapse[0].weight 0.0
                end

Notes:          
See also: getsyncount , getsynindex , getsyndest , BoG chapter 18

25.86 h

Routine Name:   h

Description:    Displays the contents of the command-history buffer.

Usage:          h
                h [start [end] ]

                star