Wave dependency in user-defined functions

I try to use wave dependency in my function so that when Wave1 is changed, Wave2 will be updated automatically.

Function Dependency_test1()
    make /O/N=5 wave1
    wave1={1,2,3,4,5}
    make /O /N=5 wave2
    wave2:=wave1
End


but always get an error "Can't use local variables in dependency formula" during compile.

This seems to work in the command line. I am not sure what I am doing wrong?

Thank you!
This appears to work:
Function Dependency_test1()
    make /O/N=5 wave1
    wave1={1,2,3,4,5}
    make /O /N=5 wave2
    SetFormula wave2,  "wave1"
End


When I use Edit  root:wave1,root:wave2 I can change values in wave1 and those in wave2 change automagically.

Hope this helps,
Kurt
To be fully safe with liberal names and data folders, you need to do something like this:
Function Dependency_test1()

// stupid example to make this point...
    String wname = "liberal name for my wave"
    make /O/N=5 $wname
    WAVE wave1 = $wname
    wave1={1,2,3,4,5}
   
// now create the dependency
    make /O /N=5 wave2
    String wave1name = GetWavesDataFolder(wave1, 2)
    SetFormula wave2, wave1name
End

If you now run this function, then go to Misc->Object Status you will see that wave2 depends on wave1 via this formula: "root:'liberal name for my wave'". Note the data folder path, and special quoting for the liberal name.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com