Accessing single wave element using wave reference

I am trying to programmatically access a single element of an existing wave using a wave reference, but receive the compile error "Can't use $ in this way in a function"

Specifically, I have many waves named for example wave0, wave1, wave2...

In my program, I am referencing these waves inside of a for loop with index i using
String waveIn = "wave"+num2str(i)


I am then trying to set the value of one element of waveOut but using the $waveIn reference:
waveOut[i] = $waveIn[desiredIndex]


What is the proper way to read the desired element from waveIn?
    String waveInStr = "wave"+num2istr(i)
    WAVE waveIn = $waveInStr
    waveOut[i] = waveIn[desiredIndex]

DisplayHelpTopic "Accessing Waves In Functions"
DisplayHelpTopic "Converting a String into a Reference Using $"

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com