This file is indexed.

/usr/share/nrn/lib/hoc/stdrun.hoc is in neuron 7.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
objref cvode
cvode = new CVode()
{load_file("stdlib.hoc", "String")}

begintemplate NEURONMainMenu // avoid some namespace pollution
public filemenu, miscellaneous_add, misclist
objref rwl_, rwf_, sf_, tobj
objref ldfile, misclist
strdef tstr, rwdname

proc init() {
	sf_ = new StringFunctions()
	if (unix_mac_pc() == 1 || unix_mac_pc() == 4) {
		rwdname = "$(HOME)/.NRNWorkingDirs"
	}else{
		rwdname = "$(NEURONHOME)/RecentWorkingDirs"
	}
	misclist = new List()
	if (ropen("RCS/nrnversion,v")) {
		ropen()
		miscellaneous_add("Archive and Hardcopy", "prjnrn()")
	}
	
}

proc miscellaneous_add() {
	misclist.append(new String($s1))
	misclist.append(new String($s2))
}

proc filemenu() {
	xmenu("File")
	xbutton("load session", "load(\"*.ses\", 1)")
	xbutton("load hoc", "load(\"*.hoc\", 0)")
	if (unix_mac_pc() != 1) {
		xbutton("load dll", "load(\"*.dll\", 2)")
	}
	xbutton("save session", "save_ses_nrnmainmenu()")
	xbutton("working dir", "change_working_dir()")
	if (unix_mac_pc() != 0) {
		xmenu("recent dir", "recent_working_dirs()")
	}
	xbutton("Print", "print_session(0)")
	xbutton("Quit", "quit()")
	xmenu()
}

proc load() {
	if (object_id(ldfile) == 0) {
		ldfile = new File()
	}
	ldfile.chooser("r", "Load", $s1, "Load", "Cancel", getcwd())
	if (ldfile.chooser()) {
		if ($2 == 2) {
			nrn_load_dll(ldfile.getname)
		}else{
			load_file($2, ldfile.getname)
		}
	}
}

proc change_working_dir() {
	if (object_id(ldfile) == 0) {
		ldfile = new File()
	}
	ldfile.chooser("d", "Directory", "", "Move To", "Cancel", getcwd())
	if (ldfile.chooser()) {
		read_recent_working_dirs()
		change_working_dir1(ldfile.dir)
	}
}

func change_working_dir1() {
	if(chdir($s1) != 0) {
		sprint(tstr, "No such directory: %s", $s1)
		continue_dialog(tstr)
		return 0
	}
	print "Changed working directory to ", $s1
	ldfile = new File()
	write_recent_working_dirs()
	if (!default_dll_loaded_) {
		if (unix_mac_pc() == 2) {
			if(nrn_load_dll("nrnmac.dll") != 0){
				default_dll_loaded_ = 1
			}
		}
		if (unix_mac_pc() == 3) {
			if (nrn_load_dll("nrnmech.dll") != 0) {
				default_dll_loaded_ = 1
			}
		}
	}
	return 1
}

proc change_working_dir2() {
	tobj = rwl_.object($1)
	rwl_.remove($1)
	if (change_working_dir1(tobj.s) == 0) {
		while (string_dialog("Working Directory", tobj.s)) {
			if (change_working_dir1(tobj.s) == 1) {
				break
			}
		}
	}
}

proc read_recent_working_dirs() {local i
	rwf_ = new File()
	rwl_ = new List()
	if (rwf_.ropen(rwdname)) {
		while (!rwf_.eof()) {
			rwf_.gets(tstr)
			sf_.left(tstr, sf_.len(tstr) - 1)
			tobj = new String(tstr)
			rwl_.append(tobj)
		}
		rwf_.close()
	}
}

proc write_recent_working_dirs() {local i
	rwf_ = new File()
	tstr = getcwd()
	if (rwf_.wopen(rwdname)) {
		rwf_.printf("%s\n", tstr)
		for i=0, rwl_.count-1 {
			if (strcmp(rwl_.object(i).s, tstr) != 0) {
				rwf_.printf("%s\n", rwl_.object(i).s)
			}
			if (i > 10) break
		}
		rwf_.close()
	}
}

proc recent_working_dirs() {local i
	read_recent_working_dirs()
	for i=0, rwl_.count-1 {
		sprint(tstr, "change_working_dir2(%d)", i)
		xbutton(rwl_.object(i).s, tstr)
	}
}

proc save_ses_nrnmainmenu() {
	if (object_id(ldfile) == 0) {
		ldfile = new File()
	}
	ldfile.chooser("w", "Save Session", "*.ses", "Save", "Cancel", ldfile.dir)
	if (ldfile.chooser()) {
		ldfile.close()
		sprint(tstr, "save_session(\"%s\",\"{load_file(\\\"nrngui.hoc\\\")}\")", ldfile.getname)
		execute(tstr)
	}
}

endtemplate NEURONMainMenu

using_cvode_ = 0 // now controlled in NumericalMethodPanel
{load_file("atoltool.hoc")}
{load_file("varmeth1.hoc")}
{load_file("movierun.hoc")}
objref tobj, tobj1, nrnmainmenu_, numericalmethodpanel, pyobj
stdrun_quiet = 0
realtime=0
{units(&realtime, "s")}
screen_update_invl = .05
{variable_domain(&screen_update_invl, .01, 1e9) units(&screen_update_invl, "s")}
tstop = 5
{variable_domain(&tstop, 0, 1e9) units(&tstop, "ms")}
stoprun = 0
steps_per_ms = 1/.025
{variable_domain(&steps_per_ms, 1e-6, 1e6)}
nstep_steprun=1
runStopAt = tstop
{variable_domain(&runStopAt, 0, 1e9) units(&runStopAt, "ms")}
runStopIn = 1
{variable_domain(&runStopIn, 0, 1e6) units(&runStopIn, "ms")}
global_ra = 35.4
{variable_domain(&global_ra, 1e-3, 1e6) units(&global_ra, "ohm-cm")}
strdef temp_string_, temp_string2_
temp_string_ = "t"

proc prjnrn() {	// Project management.
	save_session("start.ses")   
	print_session(1, "prjnrnpr")
}

/* stylized control processes for nrncontrolmenu() */
{load_file("pointbsr.hoc", "PointBrowser")}
strdef tstr
{load_file("wingroup.hoc", "WindowMenu")}

if (name_declared("mapped_nrnmainmenu_") == 0) {
	mapped_nrnmainmenu_ = 0
}

proc nrnmainmenu() {
	if (mapped_nrnmainmenu_ == 1) {
		return
	}
	nrnmainmenu_ = new NEURONMainMenu()
	mapped_nrnmainmenu_ = 1
    xpanel("NEURON Main Menu")
	nrnmainmenu_.filemenu()
	buildmenu()
	toolmenu()
	graphmenu()
	vectormenu()
	windowmenu()
	helpmenu()
    xpanel(0,25)
	if (object_id(WindowMenu[0].pwm) == 0) {
		// some sessions need a PWManager which used not to
		// exist until the Window menu was used
		WindowMenu[0].pwm = new PWManager()
	}
	// also many idioms assume there is no PWManager window at this point
	//so close it.
	if (PWManager[0].manager < PWManager[0].count) {
		PWManager[0].close(PWManager[0].manager)
	}
}

proc helpmenu() {
    if (nrnpython("import webbrowser")) {
	    xmenu("Help", 1)
	    xbutton("Programmer's Reference", "nrnpython(\"webbrowser.open('https://neuron.yale.edu/neuron/static/new_doc/index.html')\")")
	    xbutton("Tutorials", "nrnpython(\"webbrowser.open('http://neuron.yale.edu/neuron/docs')\")")
	    xbutton("NEURON Forum", "nrnpython(\"webbrowser.open('https://neuron.yale.edu/phpBB/')\")")
	    xbutton("NEURON Models on ModelDB", "nrnpython(\"webbrowser.open('http://senselab.med.yale.edu/ModelDB/ModelList.cshtml?id=1882')\")")
	    xmenu()
    }
}

proc buildmenu() {local has_rxd
    has_rxd = 0
    if (nrnpython("import neuron")) {
        pyobj = new PythonObject()
        has_rxd = pyobj.neuron._has_scipy()
    }    
    xmenu("Build", 1)
    xbutton("single compartment", "load_file(\"single.hoc\") makesinglecompartment()")
    xbutton("Cell Builder", "load_file(\"celbild.hoc\") makecellbuilder()")
    xmenu("NetWork Cell")
    xbutton("From Cell Builder", "load_file(\"netbild.hoc\") makenetreadycell()")
    xbutton("Artificial Cell", "load_file(\"netbild.hoc\") makeartcelltype()")
    xmenu()
    xbutton("NetWork Builder", "load_file(\"netbild.hoc\") makenetbuilder()")
    xbutton("Linear Circuit", "load_file(\"lincir.hoc\") makeCircuit()")
//  xbutton("Channels", "channel_builder()")
    xmenu("Channel Builder")
    xbutton("Density", "load_file(\"chanbild.hoc\", \"ChannelBuild\") chanbild(1)")
    xbutton("Point", "load_file(\"chanbild.hoc\", \"ChannelBuild\") chanbild(0)")
    xmenu("import KSChan", "cbimportmenu()")
    xmenu()
    if (has_rxd) {
        xbutton("RxD Builder", "nrnpython(\"import neuron.rxd.gui\") nrnpython(\"neuron.rxd.gui.RxDBuilder()\")")
    }
    xmenu()
}
proc cbimportmenu() {local i, j
	load_file("chanbild.hoc")
	tobj = new List("KSChan")
	tobj1 = new List("ChannelBuild")
	for i=0, tobj1.count-1 { 
		j = tobj.index(tobj1.object(i).ks)
		if (j != -1) {
			tobj.remove(j)
		}
	}
	for i=0, tobj.count - 1 {
		sprint(tstr, "chanbild(%s)", tobj.object(i))
		xbutton(tobj.object(i).name, tstr)
	}
	if (tobj.count == 0) {
		xbutton("No uncontrolled KSChan", "")
	}
	objref tobj, tobj1
}
running_ = 0
proc toolmenu() {
	xmenu("Tools", 1)
	xbutton("RunControl", "nrncontrolmenu()")
//	xbutton("RunButton", "xpanel(\"Run\") xbutton(\"Init & Run\", \"run()\") xpanel()")
	xbutton("RunButton", "xpanel(\"Run\") xcheckbox(\"Init & Run\", &running_,\"runbutton()\") xpanel()")
	xbutton("VariableStepControl", "numericalmethodpanel.map()")
	xbutton("Parallel Computing", "load_file(\"parcom.hoc\", \"ParallelComputeTool\") execute(\"ParallelComputeTool[0].map()\")")
	pointprocessesmenu()
	distmechmenu()
	fittingmenu()
	impedancemenu()
	xbutton("Model View", "load_file(\"mview.hoc\", \"ModelView\") execute(\"mview()\")")
	xbutton("Movie Run", "load_file(\"movierun.hoc\") movierunpanel()")
	xmenu("Miscellaneous", "miscellaneousmenu()", 1)
	xmenu()
}

proc vectormenu() {
	xmenu("Vector", 1)
	xbutton("Save to File", "load_file(\"stdlib.hoc\",\"clipboard_save\") clipboard_save()")
	xbutton("Retrieve from File", "load_file(\"stdlib.hoc\",\"clipboard_retrieve\") clipboard_retrieve()")
	xbutton("Gather Values", "load_file(\"gatherv.hoc\") makeGatherVec()")
	xbutton("Play", "load_file(\"vplay.hoc\") makeVectorPlay()")
	xbutton("Display", "load_file(\"vecwrap.hoc\") makeVecWrap()")
	xbutton("Draw", "load_file(\"mkcurve.hoc\") makeMakeCurve()")
	xmenu()
}
proc windowmenu() {
	tobj = new WindowMenu()
	sprint(tstr, "%s.make()", tobj)
	xmenu("Window", tstr, 1)
	objref tobj
}

proc graphmenu() {
    xmenu("Graph", 1)
	xbutton("Voltage axis", "newPlotV()")
	xbutton("Current axis", "newPlotI()")
	xbutton("State axis", "newPlotS()")
	xbutton("Shape plot", "newshapeplot()")
	xbutton("Vector movie", "newvectorplot()")
	xbutton("Phase Plane", "newphaseplane()")
	xbutton("Grapher", "load_file(\"grapher.hoc\") makegrapher(1)")
    xmenu()
}

proc pointprocessesmenu() {
    xmenu("Point Processes")
    xmenu("Managers")
	xbutton("Point Manager", "load_file(\"pointman.hoc\") makeppm()")
	xbutton("Point Group", "load_file(\"pointgrp.hoc\") makeppgm()")
	xbutton("Electrode", "load_file(\"electrod.hoc\") makeelectrode()")
    xmenu()
    xmenu("Viewers", "pointmenu()")
    xmenu()
}
proc distmechmenu() {
  xmenu("Distributed Mechanisms")
    xmenu("Managers")
	xbutton("Inserter", "load_file(\"inserter.hoc\", \"Inserter\") makeinserter()")
	xbutton("Homogeneous Spec", "load_file(\"showmech.hoc\") makeshowmechanism()")
    xmenu()
    xmenu("Viewers", "distmechviewers()")
    xbutton("celsius", "celsius_panel()")
    xbutton("globalRa", "globalra_panel()")

  xmenu()
}

proc distmechviewers() {
	xbutton("Shape Name", "load_file(\"shapebox.hoc\", \"MenuExplore\") makeMenuExplore()")
	xbutton("Name Values", "nrnallsectionmenu()")
	nrnglobalmechmenu()
}

proc celsius_panel() {
	xpanel("Temperature")
	xpvalue("celsius", &celsius, 1)
	xpanel()
}
proc globalra_panel() {
	xpanel("forall Ra=global_ra")
	xvalue("global Ra", "global_ra", 1, "set_ra()", 1, 1)
	xpanel()
}

proc fittingmenu() {
	xmenu("Fitting")
	xbutton("Parameterized Function", "load_file(\"funfit.hoc\") makefitter()")
	xbutton("Run Fitter", "load_file(\"runfit.hoc\") makerunfitter()")
	xbutton("Multiple Run Fitter", "load_file(\"mulfit.hoc\") makemulrunfitter()")
	xmenu()
}

proc impedancemenu() {
	xmenu("Impedance")
	xbutton("Frequency", "load_file(\"impratio.hoc\") makeImpRatio()")
	xbutton("Path", "load_file(\"impedanx.hoc\") makeImpx()")
	xbutton("log(A) vs x", "load_file(\"logax.hoc\") makelogax()")
	xbutton("Shape", "load_file(\"attshape.hoc\") makeImpShape()")
	xmenu()
}

proc miscellaneousmenu() {local i
	xbutton("Import 3D", "load_file(\"import3d.hoc\") makeimport3dtool()")
	xmenu("Family")
	xbutton("Family", "load_file(\"family.hoc\",\"Family\") makeFamily()")
	xbutton("Command", "load_file(\"stdlib.hoc\",\"ExecCommand\") newcommand()")
	xmenu()
	xmenu("Builders")
	xbutton("Kinetic Scheme Builder", "load_file(\"kinbuild.hoc\") makekineticbuilder()")
	xmenu()
	for (i=0; i < nrnmainmenu_.misclist.count; i += 2) {
xbutton(nrnmainmenu_.misclist.object(i).s, nrnmainmenu_.misclist.object(i+1).s)
	}
}

v_init = -65
{units(&v_init, "mV")}

numericalmethodpanel = new NumericalMethodPanel()

func cvode_active() {
	if (numarg() == 1) {
		numericalmethodpanel.varstep($1)
	}
	return cvode.active()
}

func cvode_local() {
	if (numarg() == 1) {
		numericalmethodpanel.localstep($1)
	}
	return cvode.use_local_dt()
}	

proc nrncontrolmenu() {
    xpanel("RunControl")
	xpvalue("Init", &v_init, 1, "stdinit()", 1)
	xbutton("Init & Run", "run()")
	xbutton("Stop", "stoprun=1")
xvalue("Continue til", "runStopAt", 1, "{continuerun(runStopAt) stoprun=1}", 1, 1)
xvalue("Continue for", "runStopIn", 1, "{continuerun(t + runStopIn) stoprun=1}", 1,1)
	xbutton("Single Step", "steprun()")
	xvalue("t", "t", 2)
	xvalue("Tstop", "tstop", 1, "tstop_changed()", 0, 1)
	xpvalue("dt", &dt, 1, "setdt()")
	xvalue("Points plotted/ms", "steps_per_ms", 1, "setdt()", 0, 1)
	xpvalue("Scrn update invl", &screen_update_invl, 1)
//	xcheckbox("Quiet", &stdrun_quiet)
	xpvalue("Real Time", &realtime)
    xpanel()
}

func set_v_init() {local old
	old = v_init
	if (numarg(1)) {
		v_init = $1
	}
	return old
}

proc stdinit() {
	cvode_simgraph()
	realtime = 0
	setdt()
	init()
	initPlot()
}

proc init() {
	finitialize(v_init)
	// fcurrent() // no longer necessary. finitialize now
	// initializes all conductances and currents as well as states.
	// Extra initialization should normally go here.
	// If you change any states or parameters after an finitialize
	// then you should complete the initialization with
    /*
	if (cvode.active()) {
		cvode.re_init()
	}else{
		fcurrent()
	}
	frecord_init()	
    */
}

n_graph_lists = 4
objectvar graphList[n_graph_lists], graphItem, flush_list, fast_flush_list
for i=0,n_graph_lists-1 graphList[i] = new List(1)
flush_list = new List(1)
fast_flush_list = new List(1)

proc set_ra() {/* this alleviates the backward compatibility problems */
	if (numarg() == 1) {
		global_ra = $1
	}
	forall Ra = global_ra
}

proc runbutton() {
	if (running_ == 0) {
		stoprun = 1
		return
	}
	execute1("run()")
	running_ = 0
	stoprun = 0
}

proc run() {
	running_ = 1
	stdinit()
	continuerun(tstop)
}

func stoppedrun() { return stoprun }

proc setdt() {local Dt, dtnew
	if (using_cvode_) return
	Dt = 1/steps_per_ms
	nstep_steprun = int(Dt/dt)
	if (nstep_steprun == 0) {
		nstep_steprun = 1
	}
	dtnew = Dt/nstep_steprun
	if (abs(dt*nstep_steprun*steps_per_ms - 1) > 1e-6) {
		print "Changed dt"
		dt = dtnew
	}
}

eventslow=1
eventcount=0

proc continuerun() {local rt, rtstart, ts
	realtime = 0  rt = screen_update_invl  rtstart = startsw()
	eventcount=0
	eventslow=1
	stoprun = 0
	if (using_cvode_) {
		cvode.event($1)
		ts = $1
		if (cvode.use_local_dt) {
			cvode.solve(ts)
			flushPlot()
			realtime = startsw() - rtstart
			return
		}
	}else{
		ts = $1 - dt/2
	}
	while(t < ts && stoprun == 0) {
		step()
		realtime = startsw() - rtstart
		if (realtime >= rt) {
//			if (!stdrun_quiet) fastflushPlot()
			screen_update()
			//really compute for at least screen_update_invl
			realtime = startsw() - rtstart
			rt = realtime + screen_update_invl
		}
	}
	if (using_cvode_ && stoprun == 0) { // handle the "tstop" event
		step() // so all recordings take place at tstop
	}
	flushPlot()
	realtime = startsw() - rtstart
}

proc steprun() {
	step()
	flushPlot()
}

proc step() {local i
	if (using_cvode_) {
		advance()
	}else for i=1,nstep_steprun {
		advance()
	}
	Plot()
}

proc advance() {
	fadvance()
}

proc cvode_simgraph() {local i, j
	cvode.simgraph_remove()
	if (cvode.active && cvode.use_local_dt) {
		for j=0,n_graph_lists-1 {
			for i=0,graphList[j].count-1 graphList[j].object(i).simgraph()
		}
	}
}

proc initPlot(){local i, j, cnt
	if (cvode.active && cvode.use_local_dt) {
		flushPlot()
		return
	}
	for j=0,n_graph_lists-1 {
		cnt = graphList[j].count() - 1
		for (i=cnt; i >= 0; i=i-1) if (graphList[j].object(i).view_count() == 0){
			graphList[j].remove(i)
			cnt = cnt - 1
		}
		for i=0,cnt graphList[j].object(i).begin()
	}
	cnt = flush_list.count() -1
	for (i=cnt; i >= 0; i=i-1) if (flush_list.object(i).view_count() == 0){
		flush_list.remove(i)
	}
	cnt = fast_flush_list.count() -1
	for (i=cnt; i >= 0; i=i-1) if (fast_flush_list.object(i).view_count() == 0){
		fast_flush_list.remove(i)
	}
	Plot()
	flushPlot()
}

proc tstop_changed() {local i, j, cnt
	for j=0,2 {
		cnt = graphList[j].count() - 1
		for i=0,cnt {
			graphItem = graphList[j].object(i)
			graphItem.size(0, tstop, graphItem.size(3), \
				graphItem.size(4))
		}
	}
}

proc Plot() {local i, j, cnt, dt2
	if (using_cvode_) {
		dt2=0
	}else{
		dt2 = dt/2
	}
	cnt = graphList[0].count() - 1
	for i=0,cnt graphList[0].object(i).plot(t)
	cnt = graphList[1].count() - 1
	for i=0,cnt graphList[1].object(i).plot(t - dt2)
	cnt = graphList[2].count() - 1
	for i=0,cnt graphList[2].object(i).plot(t + dt2)
	cnt = graphList[3].count() - 1
	for i=0,cnt graphList[3].object(i).plot(t)
}

proc screen_update() {local i
	if (!stdrun_quiet) {
		cnt = flush_list.count() - 1
		for i=0,cnt flush_list.object(i).begin()
		for i=0,cnt flush_list.object(i).flush()
		cnt = fast_flush_list.count() - 1
		for i=0,cnt fast_flush_list.object(i).fastflush()
		fastflushPlot()
		doNotify()
	}
}

proc flushPlot() {local i, j, cnt
	screen_update()
	for j=0,n_graph_lists-1 {
		cnt = graphList[j].count() - 1
		for i=0,cnt graphList[j].object(i).flush()
	}
	cnt = flush_list.count() - 1
	if (cnt >= 0) {
		for i=0,cnt flush_list.object(i).flush()
	}
	cnt = fast_flush_list.count() - 1
	if (cnt >= 0) {
		for i=0,cnt fast_flush_list.object(i).flush()
	}
	if (!stdrun_quiet) {
		doEvents()
	}
}

proc fastflushPlot() {local i, j, cnt
	for j=0,n_graph_lists-1 {
		cnt = graphList[j].count() - 1
		for i=0,cnt graphList[j].object(i).fastflush()
	}
//	doEvents()
}

proc newPlotV() {
	newPlot(0,tstop,-80,40)
	graphItem.save_name("graphList[0].")
	graphList[0].append(graphItem)
	graphItem.addexpr("v(.5)")
}
proc newPlotI() {
	newPlot(0,tstop,-1,1)
	graphItem.save_name("graphList[1].")
	graphList[1].append(graphItem)
}
proc newPlotS() {
	newPlot(0,tstop,0,1)
	graphItem.save_name("graphList[2].")
	graphList[2].append(graphItem)
}
proc newPlot() {local w, h
	graphItem = new Graph()
	graphItem.size($1,$2,$3,$4)
	graphItem.xaxis()	// view axis for x and y
/*
	w = $2 - $1
	h = $4 - $3
	graphItem.size($1- w/10, $2+w/10, $3-h/10, $4+h/10)
*/
}
proc addplot() {
	$o1.size(0,tstop,-1,1)
	graphList[$2].append($o1)
}

proc newshapeplot() {
	if(!execute1("v", 0)) {
		continue_dialog("No accessed section: Can't start a PlotShape")
		return
	}
	graphItem = new PlotShape()
	fast_flush_list.append(graphItem)
	graphItem.save_name("fast_flush_list.")
}
proc newvectorplot() {
	graphItem = new Graph()
	flush_list.append(graphItem)
	graphItem.save_name("flush_list.")
}
proc newphaseplane() {
	graphItem = new Graph()
	string_dialog("x axis expression", temp_string_)
	graphItem.xexpr(temp_string_)
	sprint(temp_string_, "x-axis: %s", temp_string_)
	graphItem.label(.5, .9, temp_string_)
	
	graphItem.save_name("graphList[3].")
	graphList[3].append(graphItem)
	temp_string_ = "t"
}


proc channel_builder() {
	if (name_declared("nrnccmb_Channels") == 0) {
print "Loading Robert Cannon's Catacomb channel builder. This may take a minute."
	}
	if (load_java("nrnccmb.Channels")) {
		tobj = new List("nrnccmb_Channels")
		if (tobj.count == 0) {
			execute("tobj = new nrnccmb_Channels()")
		}else{
			tobj = tobj.object(0)
		}
		tobj.map()
		objref tobj
	}else{
continue_dialog("The Catacomb simulator (ccmb.jar) is not in the CLASSPATH.")
	}
}