Operations on all waves inside root

Hello,

I am trying to perform operations on all waves beginning with "Cell" in root (multiply them by 1000). The code is not throwing any error but it doesn't appear to be working for me. I would appreciate any feedback. This is what I have so far:

Function voltage()



string list
string tracename
variable index =0
SetDataFolder root:
list = WaveList("Cell*", ";", "")  //get wavelist matching cell
do
    tracename=StringFromList(index,list)
    if (strlen(tracename) ==0)
        break //ran out of waves
    endif
    Wave w = $tracename
    w *=1000
    index+=1
   
while (index<= strlen(list))
   


End  

<pre><code class="language-igor">
Just reading through your code I don't see problems (but I sometimes fail to see problems :). Are you certain that the current data folder is root? Your code will work on whatever is the current data folder.

And "doesn't appear to be working" doesn't say much. Do you get run-time errors? Or a bad result? or the waves simply aren't altered?

You may be able to figure out the problem using Igor's symbolic debugger: DisplayHelpTopic "The Debugger"

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
I realized that I should be using Itemsinlist NOT strlen but even after I changed the code it still is not working. When I print itemsinlist it gives me a value of 1 instead of correctly counting the items. This is probably where it is going wrong.
Try printing list. It should be a semicolon-separated list of wave names.

Your use of strlen is fine. StringFromList returns "" when it runs out of items.

This is wrong:
while (index<= strlen(list))


It should be:
while(1)

The loop will be terminated by the break statement.

You could write:
while(index < ItemsInList(list))

but that is not necessary.

BTW, "tracename" is misleading. WaveList returns wave names. TraceNameList returns trace names.
I am getting the right operations with this but the print itemsinlist output still doesn't make sense to me.

do
    tracename=StringFromList(index,list)
    if (itemsinlist(tracename) ==0)
        break //ran out of waves
    endif
    Wave w = $tracename
    w /=1000
    index+=1
   
while (index<= itemsinlist(list))

print list
Cell_10_0489;Cell_10_0487;Cell_10_0488;Cell_10_0490;Cell_10_0491;Cell_10_0492;Cell_10_0493;Cell_10_0494;Cell_10_0495;Cell_10_0496;Cell_10_0497;Cell_10_0498;Cell_10_0499;Cell_10_0500;Cell_10_0501;
Cell_10_0502;Cell_10_0503;Cell_10_0504;Cell_10_0505;Cell_10_0506;Cell_10_0507;Cell_10_0508;Cell_10_0509;Cell_10_0510;Cell_10_0511;Cell_10_0512;Cell_10_0513;Cell_10_0514;Cell_10_0515;Cell_10_0516;
Cell_10_0517;Cell_10_0518;Cell_10_0519;Cell_10_0520;Cell_10_0521;Cell_10_0522;Cell_10_0523;Cell_10_0524;Cell_10_0525;Cell_10_0526;Cell_10_0527;Cell_10_0528;Cell_10_0529;Cell_10_0530;Cell_10_0531;
Cell_10_0532;Cell_10_0533;Cell_10_0534;Cell_10_0535;Cell_10_0536;Cell_10_0537;Cell_10_0538;Cell_10_0539;Cell_10_0540;Cell_10_0541;Cell_10_0542;Cell_10_0543;Cell_10_0544;Cell_10_0545;Cell_10_0546;
Cell_10_0547;Cell_10_0548;Cell_10_0549;Cell_10_0550;Cell_10_0551;Cell_10_0552;Cell_10_0553;Cell_10_0554;Cell_10_0555;Cell_10_0556;Cell_10_0557;Cell_10_0558;Cell_10_0559;Cell_10_0560;Cell_10_0561;
 
print itemsinlist("list",";")
1