How to input value from its x-axis value but not from the point position

Thank you IGOR Exchange. I have successfully generated a code for ratiometric measurement of my data. These data are in lambda format (wavelength vs. intensity)
I added two functions in a menu. One targets individual spectrum ratio metric measurement and another targets all spectra in the same graph.

To obtain ratio value, i have to select two points in spectrum (one call donor; another call acceptor). The numberator and denominator positions are not constant in my experiments, so I have to create an input window for specific ratio measurement.
Here, the number that I use is based on point position (red arrow). Now, I would like to use lambda position (blue arrows) to define the ratio, can you point me how to do it?

Here is the code:

Menu "Ratiometric",dynamic
    TraceNameList ("",";",1), donor_acceptor()
"Ratio all",   donor_acceptorAll()
End


Function donor_acceptor()
    variable donor
    variable acceptor
    prompt donor,"donor peak"
    Prompt acceptor,"acceptor peak"
    Doprompt "Enter values", donor,acceptor
    if (V_flag == 0)
        ratiometric(donor, acceptor)
    endif
end

Function ratiometric(donor,acceptor)
variable donor,acceptor
    GetLastUserMenuInfo     // sets S_value, V_value, etc.
    ratiometric_value(S_value,donor,acceptor)
end

Function ratiometric_value(tracename,donor,acceptor)
string tracename
variable donor,acceptor
wave w= traceNametowaveRef("",traceName)
    wavestats/q w

    variable xPeak = V_maxloc
    VARIABLE ratioValue = w[donor]/w[acceptor]
    String TextItRatio
    sprintf TextItRatio, "\\Z09 \\K(0,65280,0)\\ON  \rRatio=%g",ratioValue
        Tag /F=2/S=3/A=MT/B=(0,0,0)  $tracename,xPeak, TextItRatio
   
End
 
Function donor_acceptorAll()
    variable donor
    variable acceptor
    prompt donor,"donor peak"
    Prompt acceptor,"acceptor peak"
    Doprompt "Enter values", donor,acceptor
    if (V_flag == 0)
        ratiometricall(donor, acceptor)
    endif
end

Function ratiometricall(donor,acceptor)
variable donor,acceptor
    String list = TraceNameList("", ";", 1)
    String tracename

    Variable index = 0
    do
        traceName = StringFromList(index, list)
        if (strlen(traceName) == 0)
            break // No more traces.
        endif
     ratiometric_value(tracename,donor,acceptor)
        index += 1
    while(1)
end


Thank you very much! Sorry for redundant or messy coding
temp.png (108.85 KB)
Does your user get the "donor" and "acceptor" values that are entered in response to the DoPrompt command by inspecting the data table? If so, a simple solution is to display the data table with wave scaling. This can be done from the New Table dialog by selecting the "Edit index and data columns" radio button. Then the user enters scaled (x) values instead of point numbers.

If you do this, then remember to use parentheses to index into the wave with scale values. That is change

VARIABLE ratioValue = w[donor]/w[acceptor]    //point value indexing

to

VARIABLE ratioValue = w(donor)/w(acceptor)   //scale value indexing

Let us know if the above suggestion helps. If not, then maybe you need to clarify your request.
It worked. I have all my data in scale value indexing. Now, I really learned the meaning of [] vs. ().
Thanks!

jtigor wrote:
Does your user get the "donor" and "acceptor" values that are entered in response to the DoPrompt command by inspecting the data table? If so, a simple solution is to display the data table with wave scaling. This can be done from the New Table dialog by selecting the "Edit index and data columns" radio button. Then the user enters scaled (x) values instead of point numbers.

If you do this, then remember to use parentheses to index into the wave with scale values. That is change

VARIABLE ratioValue = w[donor]/w[acceptor]    //point value indexing

to

VARIABLE ratioValue = w(donor)/w(acceptor)   //scale value indexing

Let us know if the above suggestion helps. If not, then maybe you need to clarify your request.

Glad it worked for you.

You could also get the scaled or point position by showing the graph info bar (Control-I, OR Graph Menu > Show Info), placing a cursor on the trace and moving to the point of interest. The info bar at the bottom of the graph will show the x & y values of the point and the point position.