Importing Wave

Good evening, I would need a help to create a graphical interface.
I created a funazione "highpass" to apply a filter to my data.
I created a simple GUI, but I can not load and set the best parameters.
I wish every time I load a wave, this has an automatic renaming, and that this name be scelato for example chosen by the operator, as in the box that I created. so every time you load a new wave, the first will have to remain still in memory and plotted, without being overwritten.
This is my procedure:

#pragma rtGlobals=3     // Use modern global access method and strict wave access.

Menu "Vibration Filter"
    "FTT",  VRB(); VF()
   
EndMacro

Function VRB()
    variable/G win
    string/G waveoutname
    string/g wm
    wave wavein = wm
end

Window VF() : Panel
    PauseUpdate; Silent 1       // building window...
    NewPanel /W=(10,60,260,540)
   
    SetVariable setvar_hf title="win", pos={23,112}, size={133, 20}, value=win; DelayUpdate
    SetVariable setvar_hf limits={-inf,inf,0}
    SetDrawEnv fsize= 12; DelayUpdate
    SetDrawEnv fname="Calibri"
   
    SetVariable setvar_waven title="wave in", pos={23, 88}, size={130, 20}, value=wm; DelayUpdate
    SetDrawEnv fname= "Calibri"
    SetDrawEnv fsize= 10;DelayUpdate
   
    Button button_HFF, pos={64,212}, size={99,41}, proc=VFB, title="High PSS"
    SetDrawEnv fname= "Calibri"
    Button button_HFF, fSize=14, fStyle=1
       
    SetVariable setvar_WOUT title="waveout name",pos={10, 140},size={174,16}, value=waveoutname; DelayUpdate
    SetDrawEnv fname= "Calibri"
   
   
    Button button_loadwave, pos={18,28}, size={88,28}, proc=ButtonLWin, title="LOAD Wavein"

end



Function VFB(ctrlName) : ButtonControl
    string ctrlName
    NVAR win
    SVAR waveoutname
    SVAR wm
    wave/z wavein
    highpass(wavein, win, waveoutname)
end




Function/WAVE highpass(wavein, win, waveoutname)
    wave wavein
    variable win
    String waveoutname
    make/O/N=(numpnts(wavein)-win+1) wavetmp, waveout, waveout2
    wavetmp= wavein[win/2+p-1]
    waveout=sum(wavein, pnt2x(wavein, p), pnt2x(wavein, p+win-1))/win // moving average 1 Hz
    waveout2=wavetmp-waveout
    duplicate/O waveout2, $waveoutname
    Wave wOut=$waveoutname
    wOut=waveout2
end



// LOAD WAVE
Function loadewavein()
    loadwave/G/N/O/L={0,0,0,1,1}
   
end

Function ButtonLWin(ctrlName) : ButtonControl
    string ctrlName
    loadewavein()
end
kachy_89P wrote:
ok , but how do I assign the name of the new wave loaded in wavein ?


If I understand your question... one method is to add a Set Variable control to the panel and use ControlInfo to get the value entered in the control. The output variable "S_value" will hold this. You will have to be careful in entering wave names or providing error checking to be sure the string will be a legal name.
Why does your panel have all of those
    SetDrawEnv fname= "Calibri"
    SetDrawEnv fsize= 10;DelayUpdate


commands? They're not doing anything, because there are no DrawText, etc commands that would be affected by them.

If you want to set the controls font and size use the Control dialogs to set them.

Also, this in this code:
Function VRB()
    variable/G win
    string/G waveoutname
    string/g wm
    wave wavein = wm
end


The wave wavein = wm part isn't useful: once the function ends the wavein wave reference disappears (it is local to the function.)

If that is just an unfinished part of the code and you intend to use the wavein reference, it should probably be something more like
wave wavein = $wm
// do something with the wave



--Jim Prouty
Software Engineer, WaveMetrics, Inc.
JimProuty wrote:
Why does your panel have all of those
    SetDrawEnv fname= "Calibri"
    SetDrawEnv fsize= 10;DelayUpdate


commands? They're not doing anything, because there are no DrawText, etc commands that would be affected by them.

If you want to set the controls font and size use the Control dialogs to set them.

Also, this in this code:
Function VRB()
    variable/G win
    string/G waveoutname
    string/g wm
    wave wavein = wm
end


The wave wavein = wm part isn't useful: once the function ends the wavein wave reference disappears (it is local to the function.)

If that is just an unfinished part of the code and you intend to use the wavein reference, it should probably be something more like
wave wavein = $wm
// do something with the wave



--Jim Prouty
Software Engineer, WaveMetrics, Inc.


Yes, in fact those lines come from another part of the code which I then deleted .
I took your advice inserting $ wm in that function , but whenever I try to avvire " highpass " from the window that I created me always comes out the same mistake :

"Whilw excuting Make, the following error occurred: the numeber of points in a wave must be between 0 and 2147 milion.

perfect, so I solved by editing the code:

Menu "Vibration Filter"
    "FTT",  VRB(); VF()
 
EndMacro
 
Function VRB()
    variable/G win
    string/G waveoutname
    string/g wm
    wave wavein
end
 
Window VF() : Panel
    PauseUpdate; Silent 1       // building window...
    NewPanel /W=(10,60,260,540)
    SetVariable setvar_hf title="win", pos={23,112}, size={133, 20}, value=win; DelayUpdate
    SetVariable setvar_hf limits={-inf,inf,0}
    SetVariable setvar_waven title="wave in", pos={23, 88}, size={130, 20}, value=wm; DelayUpdate
    Button button_HFF, pos={64,212}, size={99,41}, proc=VFB, title="High PSS"
    Button button_HFF, fSize=14, fStyle=1
    SetVariable setvar_WOUT title="waveout name",pos={10, 140},size={174,16}, value=waveoutname; DelayUpdate
    Button button_loadwave, pos={18,28}, size={88,28}, proc=ButtonLWin, title="LOAD Wavein"
end
 
 
 
Function VFB(ctrlName) : ButtonControl
    string ctrlName
    NVAR win
    SVAR waveoutname
    wave/z wavein
    highpass(wavein, win, waveoutname)
end
 
 
 
 
Function/WAVE highpass(wavein, win, waveoutname)
    wave wavein
    variable win
    String waveoutname
Svar wm
wave wavein= $wm

    make/O/N=(numpnts(wavein)-win+1) wavetmp, waveout, waveout2
    wavetmp= wavein[win/2+p-1]
    waveout=sum(wavein, pnt2x(wavein, p), pnt2x(wavein, p+win-1))/win // moving average 1 Hz
    waveout2=wavetmp-waveout
    duplicate/O waveout2, $waveoutname
    Wave wOut=$waveoutname
    wOut=waveout2
display $waveoutname
end
 
 
 
// LOAD WAVE
Function loadewavein()
    loadwave/G/N/O/L={0,0,0,1,1}
 
end
 
Function ButtonLWin(ctrlName) : ButtonControl
    string ctrlName
    loadewavein()
end