Announcement

Collapse
No announcement yet.

Function Paramaters: In Main Only?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Function Paramaters: In Main Only?

    I have searched the KB and can not seem to find an answer to the following question.

    I am using Function Paramaters in one of my existing studies. The study has a Function Main() section, then under that section, there is a Function on Action1() section. When I try to put a paramater from the Function Paramaters in the Function on Action1() section, it does not appear to work.

    My questions is, does a paramater from Function Paramaters have to be within the Function Main() section?

    In the code below, what I am trying to accomplish is to play a sound only if the paramater Sound is = to 1.

    PHP Code:

    function preMain() {
     
        var 
    fp1 = new FunctionParameter("ADXr"FunctionParameter.NUMBER);
            
    fp1.setLowerLimit(0);
            
    fp1.setDefault (3);   

        var 
    fp2 = new FunctionParameter("Sound"FunctionParameter.NUMBER);
            
    fp2.setLowerLimit(0);
        
    fpt.setUpperLimit(1)
            
    fp2.setDefault (0); 
        

    }

    function 
    main(ADXr) {

        var 
    vADXDM = new ADXDMStudy(ADXr);

        if (
            
    vADXDM.getValue(ADXDMStudy.PDI) > vADXDM.getValue(ADXDMStudy.NDI)
           ) 
    onAction1()
           else if (
            
    vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI)
           ) 
    onAction2();

        return new Array(
            
    vADXDM.getValue(ADXDMStudy.PDI),
            
    vADXDM.getValue(ADXDMStudy.NDI)
            
        );
    }

    function 
    onAction1(Sound) {
         
        
    setBarBgColor(Color.RGB(192,255,160));
        if (
    vLastAlert != Sound 1Alert.playSound ("C:\\ProgramFiles\\eSignal Pro\\Sounds\\Ding.wav");
        
    vLastAlert 1;
       } 
    Any help would be greatly appreciated.

    Regards,
    ZMendel

  • #2
    Re: Function Paramaters: In Main Only?

    zmendel
    In order for it to work you need to first include all the available parameters in the arguments of function main() eg
    PHP Code:
    function main(ADXrSound){ 
    Then when you call the OnAction1() function you need to also pass that parameter in that call ie
    PHP Code:
    if(myCondition )
        
    OnAction1(Sound
    Once you do that the parameter will be passed on to the function which will also need to have it included in its arguments like you already have it in your script
    Alex


    Originally posted by zmendel
    I have searched the KB and can not seem to find an answer to the following question.

    I am using Function Paramaters in one of my existing studies. The study has a Function Main() section, then under that section, there is a Function on Action1() section. When I try to put a paramater from the Function Paramaters in the Function on Action1() section, it does not appear to work.

    My questions is, does a paramater from Function Paramaters have to be within the Function Main() section?

    In the code below, what I am trying to accomplish is to play a sound only if the paramater Sound is = to 1.

    PHP Code:

    function preMain() {
     
        var 
    fp1 = new FunctionParameter("ADXr"FunctionParameter.NUMBER);
            
    fp1.setLowerLimit(0);
            
    fp1.setDefault (3);   

        var 
    fp2 = new FunctionParameter("Sound"FunctionParameter.NUMBER);
            
    fp2.setLowerLimit(0);
        
    fpt.setUpperLimit(1)
            
    fp2.setDefault (0); 
        

    }

    function 
    main(ADXr) {

        var 
    vADXDM = new ADXDMStudy(ADXr);

        if (
            
    vADXDM.getValue(ADXDMStudy.PDI) > vADXDM.getValue(ADXDMStudy.NDI)
           ) 
    onAction1()
           else if (
            
    vADXDM.getValue(ADXDMStudy.PDI) < vADXDM.getValue(ADXDMStudy.NDI)
           ) 
    onAction2();

        return new Array(
            
    vADXDM.getValue(ADXDMStudy.PDI),
            
    vADXDM.getValue(ADXDMStudy.NDI)
            
        );
    }

    function 
    onAction1(Sound) {
         
        
    setBarBgColor(Color.RGB(192,255,160));
        if (
    vLastAlert != Sound 1Alert.playSound ("C:\\ProgramFiles\\eSignal Pro\\Sounds\\Ding.wav");
        
    vLastAlert 1;
       } 
    Any help would be greatly appreciated.

    Regards,
    ZMendel

    Comment

    Working...
    X