Why does this loop for wave assignments not work?

I have been stumped. Something that should be dirt simple is not working. This code bombs on the second loop with a wave assignment error "Attempt to operate on .. null (missing) wave". Yet I can run each list item separately and it works.

I have perhaps a mild flu and maybe my head is just not right from it. But ... what am I missing here?

Function CreatePseudoLangmuir()

    // data folders
   
    DFREF rd = root:rawdata
    DFREF an = root:analysis
   
    // local variables with file names
   
    string rdList = "T25;T40;T50;"
    string anList = "msvC23;msvC40;mvsC50;"
    string therd, thean
   
    variable ic, nt = 3
   
    // process the files
   
    for (ic=0;ic<nt;ic+=1)
   
        therd = StringFromList(ic,rdList)
        thean = StringFromList(ic,anList)
       
        WAVE/SDFR=rd wrd = $therd
        WAVE/SDFR=an wan = $thean
       
        // equilibrium amount absorbed per amount of resin
        wan[][0] =  (wrd[p][1] - wrd[p][2])/ wrd[p][0]
        // equilibrium concentration
        wan[][1] = wrd[p][2]
           
    endfor
   
    return 0

end
The following does not generate an error so...
Function test()
 
    // data folders
    newDataFolder/o/s rawdata
    make/o/n=(4,6) T25,T40,T50
   
    SetDataFolder root:
    newDataFolder/o/s analysis
    Make/o/n=(4,6) msvC23,msvC40,mvsC50
    SetDataFolder root:
   
    DFREF rd = root:rawdata
    DFREF an = root:analysis
 
    // local variables with file names
 
    string rdList = "T25;T40;T50;"
    string anList = "msvC23;msvC40;mvsC50;"
    string therd, thean
 
    variable ic, nt = 3
 
    // process the files
 
    for (ic=0;ic<nt;ic+=1)
 
        therd = StringFromList(ic,rdList)
        thean = StringFromList(ic,anList)
 
        WAVE/SDFR=rd wrd = $therd
        WAVE/SDFR=an wan = $thean
 
        // equilibrium amount absorbed per amount of resin
        wan[][0] =  (wrd[p][1] - wrd[p][2])/ wrd[p][0]
        // equilibrium concentration
        wan[][1] = wrd[p][2]
 
    endfor
 
    return 0
 
end
Turn debugging and WAVE checking on. When Igor breaks, check the value of therd and thean and the associated wave reference variables.
My guess at a very simple error is that the third analysis wave should be msvC50 not mvsC50. A.G. can run the code if the waves are created with those names, but what about the real example?
I found the mistake. As noted, the existing wave names were mvsC not msvC. Amazing what a good night's sleep can do to clear a fuzzy head cold.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville