// This template creates the Basal Path lists, starting from the
// section attached to the soma and ending with the basal tip section 
// written by Yiota Poirazi, July 2001, poirazi@LNC.usc.edu
// modified for working with the new Oblique Sectionlists by Jose Gomez jfcgomez@ull.es
// I changed  the loop "forsec"


begintemplate BasalPath

public basal_dtrunk_to_tip, basal_trunk_section, root_basal

strdef sexec

objref basal_trunk_section
strdef basal_trunk_section_name

objref root_basal
strdef root_basal_name

objref basal_tip_section
strdef basal_tip_section_name

objref basal_path

proc init () {
  sec_count=0

  forsec $o1 {
	
	if(sec_count==0){
			basal_tip_section    = new SectionRef()
    			basal_tip_section_name=secname()		
	}

	sec_count+=1
  }
sec_count-=1
i=0
  forsec $o1{
	if (sec_count==i){
		distance(0,1)
		basal_trunk_section  = new SectionRef()
		basal_trunk_section_name=secname()
	}
	
	if ((sec_count-1)==i){
		root_basal    = new SectionRef()
       		root_basal_name=secname()
	
	}

	i+=1	

  }



  access root_basal.sec
  distance(0,0)
  access basal_tip_section.sec
  basal_dtrunk_to_tip=distance(1,1)

//printf("BasalPath basal_trunk_section: %s root_basal: %s basal_tip_section: %s distance between root_basal and basal_tip_section: %g\n", basal_trunk_section_name, root_basal_name, basal_tip_section_name, basal_dtrunk_to_tip)
}

endtemplate BasalPath