help programming :)

Hi every body
I want to use a button for running a new experiment witch content 4 waves , so i want to save it in 4 roots (TT, RR, PP, LL), witch i have it already,
this is the code

// Chargement des données
Function ButtonProc(ctrlName) : ButtonControl
String ctrlName
LoadWave/N/G/K=1/Q
Duplicate/O wave0 TT
Duplicate/O wave1 PP
Duplicate/O wave1 RR
Duplicate/O wave1 LL
but
that not work
my aim is to: click in the buttom and charge " wave 0, wave1, wave 2and wave3" and after that save wave0 in TT , wave1 in PP ..

Thank you for your help
You need to be more specific on what does not work. I see many problems with your posted code fragment, but probably you are just leaving out information on your actual program. First, you do not seem to pass anything to LoadWave so that would fail already. Can you do the individual steps successfully from the command line and they just don't work when combined into your function? Also it would help if you write the Igor version you are using.
Start from the beginning. Write your function without using a button code.

Function LoadMyData(...)
...
end


Debug this until it works as you want. You can call it from the command line. Once it works, create a panel with a button procedure. Call your function from within the button procedure.

As a side note, you should use the newer syntax for button procedures. The newer syntax will be generated automatically for you when you add a button to a panel, edit the button, and choose New Procedure as its action item.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
jjweimer and chozo thnak you guys, finaly i succed to have the buttom ,
i have an ather problem , witch is making some statistique of a wave( max, min , Sdev..), and that will be done between two cursor, the first cursor will be the rising edge and the second one will be the falling edge
but the problem is that in compling, it show me that error
Conflict creatingV_ or S_ variable. probebly user's NVAR, SVAR or wrong type this is an extract of the code program

this is an extract of the code program

//variables
variable XL1=0,XL2=5, VLL_max, XR1,XR2,XT1,XT2
variable ii=0
Variable/G V_rms, V_avg, V_max, V_min, V_sdev, V_avg



// placing the cursors
do

FindLevel/EDGE=1/R=(XL1,XL2) LL,0.05 // rising edge
XL1=V_levelX
XL2=XL1+5 // 5 seconds after
FindLevel/EDGE=2/R=(XL1,XL2) LL,-0.05 // falling edge
XL2=V_LevelX


// extracting statistics
waveStats/Q/R=(XL1,XL2) LL
LL_rms[ii]=V_rms
LL_avg[ii]=V_avg
LL_max[ii]=V_max
LL_min[ii]=V_min
LL_sdev[ii]=V_sdev

how can i have my statistics without having this error
i realy apreciate your help
souhail wrote:

Variable/G V_rms, V_avg, V_max, V_min, V_sdev, V_avg


you can delete this line. WaveStats will create those variables (this is where the error comes from), but you can reference them without declaration in your function.
thank you Chrlie
but now the error is
must use WAVE NVAR and SVAR to access global waves, variables and strings with #pragma rtGlobals=1
Error in procedure ...
LL_rms[ii]=V_rms
souhail wrote:
thank you Chrlie
but now the error is
must use WAVE NVAR and SVAR to access global waves, variables and strings with #pragma rtGlobals=1
Error in procedure ...
LL_rms[ii]=V_rms


Post the entire function; you're making it hard for us to help you by posting only pieces of the code.

Using Variable/G V_rms isn't the problem; I don't see a declaration for LL_rms.
You need to either pass it in as a parameter or have a WAVE LL_rms= root:LL_rms statement before referencing (using) LL_rms.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
JimProuty wrote:
...Post the entire function; you're making it hard for us to help you by posting only pieces of the code....


And please ...

* INDENT YOUR CODE LINES
* Post the code within the html tags <igor> and </igor> so that, when you preview your post, your code looks like this ...

Function MyFunction(...)
     variable ...

     first line
     if ...
         indented again here ...
         ...
     ....
     return 0
end


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville