Function to work on strings on a list
epiphenom
The error I get now: "Can't use $ in this way in a function"
Function doit()
String list = "A;B;C;D"
String theWave
Variable index = 0
thewave = StringFromList(index,list)
do
Duplicate $thewave +"_test", $thewave +"_test_1"
$thewave+"_test_1"[1,] = $thewave+"_test_1"[p-1]
Display $thewave +"_test_1"
index += 1
while (index <= 3)
End
String list = "A;B;C;D"
String theWave
Variable index = 0
thewave = StringFromList(index,list)
do
Duplicate $thewave +"_test", $thewave +"_test_1"
$thewave+"_test_1"[1,] = $thewave+"_test_1"[p-1]
Display $thewave +"_test_1"
index += 1
while (index <= 3)
End
$(somewave + "_somestring") // this is correct
Here is a different version.
string strList
string theSource, theNew
variable index, np = ItemsInList(strList)
for (index=0;index<np;index+=1)
theSource = StringFromList(index,strList) + "_test"
theNew = theSource + "_1"
Duplicate $theSource, $theNew
wave swave = $theSource
wave nwave = $theNew
nwave[1,] = swave[p-1]
Display swave
endfor
return 0
end
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
March 4, 2015 at 09:18 am - Permalink
wave newwave=$thewave +"_test_1"
newwave[1,] =newwave[p-1]
should work, although the sense of the assignment with "[1,]" and "[p-1]" is unclear to me (copying the first value into the whole wave can be done easier).
@jjweimer
"
$somewave + "_somestring" // this is wrong
": This is not really wrong ("$" has lower priority than "+"), but in general I agree that parentheses help if the order of execution is unclear.And for curiosity:
Which Igor-Version is
CountofItems
from? My Igor 6 usesItemsInList
.Why is the index increased twice?
March 4, 2015 at 03:43 am - Permalink
Yes. I will fix these two mistakes in my posting.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
March 4, 2015 at 09:17 am - Permalink