begin data lrename.py 
import linedb

def RenameSpecies(OldSpecies,NewName):
  leng = len(linedb.linesOut)
  print ("Renaming   "+OldSpecies+"   to   "+NewName)
  for i in range(leng):
    l = linedb.linesOut[i]
    if (l.species == OldSpecies): 
      linedb.linesOut[i].species = NewName
   
  return
end data lrename.py  
!
begin procedure rename_species
  python RenameSpecies("&1" , "&2")  ! Note the space before and after the comma
end procedure
!
use in jpl ! cdms
use out &1imager.linedb
!
! Load the "Rename" script
python lrename.py
!
define charac*14 SPECIES[1] 
!
let species "HCO+ v=0,1,2" "CN, v = 0, 1" /RESIZE
define charac*14 shorts /like species
let shorts "HCO+"  "CN"
for is 1 to size(species)
  SELECT /SPECIES 'species[is]' /Frequency 70E3 380E3 /ENERGY 300
  @ rename_species 'species[is]'  'shorts[is]' 
  if lines%n.gt.1 then
    INSERT 
  else
    SAY "nothing found for "'species[is]'
    PAUSE
  endif
next
delete /var shorts
!
! Disk ones
let species CO C-13-O CO-18 CO-17 CS HCN HC-13-N HCN-15 HN-15-C HNC HNC-13 NNH+ SO H2S H2CO CCH  -
   HC-13-O+ C-13-N DCN DCO+ H2CS c-C3H2 SO2 C-13-S CS-34 SO+ HCCCN /RESIZE
for ispec /in species
  SELECT /SPECIES 'ispec' /Frequency 70E3 380E3 /ENERGY 300
  if lines%n.gt.1 then
    INSERT 
  else
    SAY "nothing found for "'ispec'
    PAUSE
  endif
next
!
! Only in CDMS 
use in cdms
let species CN-15 /resize
for ispec /in species
  SELECT /SPECIES 'ispec' /Frequency 70E3 380E3 /ENERGY 300
  if lines%n.gt.1 then
    INSERT 
  else
    SAY "nothing found for "'ispec'
    PAUSE
  endif
next
