Help with strings
PiStosHiO17
I have a number of waves named:
alp, bet, bAlp, bBet, blpCPM, betCPM, balpCPM, bbetCPM, alpBKG, betBKG
I am trying to write a script that defines a number and adds the number to the end of them. For example, if I wanted to add the number 160, I would change their names to
alp160, bet160, bAlp160, bBet160, blpCPM160, betCPM160, balpCPM160, bbetCPM160, alpBKG160, betBKG160
Can you help me?
PiSTosHiP
Make/O alp, bet, bAlp, bBet, blpCPM, betCPM, balpCPM, bbetCPM, alpBKG, betBKG
String listOfWaves="alp;bet;bAlp;bBet;blpCPM;betCPM;balpCPM;bbetCPM;alpBKG;betBKG;"
RenameWaves(listOfWaves,160)
End
Function RenameWaves(listOfWaveNames,suffixNum)
String listOfWaveNames
Variable suffixNum
Variable i, n=ItemsInList(listOfWaveNames)
for( i=0; i<n; i+=1 )
String name= StringFromList(i,listOfWaveNames)
String newName = name + num2istr(suffixNum)
Rename $name, $newName
endfor
End
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
April 28, 2012 at 09:25 am - Permalink
I will try it out.
April 28, 2012 at 09:47 am - Permalink