appending same data to right axis

I am trying to append same data to left and right axis.
but error occures with wave name which I cannot solve.
My wave names are -0.5 V etc, so it should be typed as '-0,5 V'.
it works with commend windows but not with procedures.
It would be grateful if experts give some valuable comment on that.


Function plotfordisplay()


        //add logscale on right axis
        wave VG
        String traces=TraceNameList("",";",3)

        variable i
            for (i=0; i<itemsinlist(traces); i+=1)
                String trace = Stringfromlist(i, traces)
                wave appendaa = $trace
                appendtograph/R appendaa vs VG
            endfor
end
I think you need TraceNameToWaveRef to reference your waves.

Here is an example, where I have modified your function, and made some example data so as to have a self contained snippet that illustrates the point (this is always a good idea!).
Function plotfordisplay()
        //add logscale on right axis
        wave VG
        String traces=TraceNameList("",";",3)
 
        variable i
            for (i=0; i<itemsinlist(traces); i+=1)
                String trace = Stringfromlist(i, traces)
                wave appendaa = TraceNameToWaveRef("", trace)
                appendtograph/R appendaa vs VG
            endfor
        ModifyGraph log(right)=1
end

Function doStuff()
    // make some fake data
    Make/O/D/N=20 VG = x
    Make/O/D/N=20  '-0,5 V' = gnoise(0.1) + exp(x/10)
    Make/O/D/N=20 '-1,0 V' = gnoise(0.1) + (x/10)^2
    Make/O/D/N=20 '-1,5 V' = gnoise(0.1) + 1.5
   
    // Make initial graph
    Display '-0,5 V'  vs VG
    AppendToGraph '-1,0 V' vs VG
    AppendToGraph '-1,5 V' vs VG
   
    // call the function
    plotfordisplay()
End


Hope this helps,
Kurt
You might also want to have a look on "liberals names". The "-0" is causing trouble with various commands but automatic quotes might help...

displayhelptopic "Programming with Liberal Names"
displayhelptopic "PossiblyQuoteName"


HJ
It perfectly works for me.
I appreciate your help!

KurtB wrote:
I think you need TraceNameToWaveRef to reference your waves.

Here is an example, where I have modified your function, and made some example data so as to have a self contained snippet that illustrates the point (this is always a good idea!).
Function plotfordisplay()
        //add logscale on right axis
        wave VG
        String traces=TraceNameList("",";",3)
 
        variable i
            for (i=0; i<itemsinlist(traces); i+=1)
                String trace = Stringfromlist(i, traces)
                wave appendaa = TraceNameToWaveRef("", trace)
                appendtograph/R appendaa vs VG
            endfor
        ModifyGraph log(right)=1
end

Function doStuff()
    // make some fake data
    Make/O/D/N=20 VG = x
    Make/O/D/N=20  '-0,5 V' = gnoise(0.1) + exp(x/10)
    Make/O/D/N=20 '-1,0 V' = gnoise(0.1) + (x/10)^2
    Make/O/D/N=20 '-1,5 V' = gnoise(0.1) + 1.5
   
    // Make initial graph
    Display '-0,5 V'  vs VG
    AppendToGraph '-1,0 V' vs VG
    AppendToGraph '-1,5 V' vs VG
   
    // call the function
    plotfordisplay()
End


Hope this helps,
Kurt