Announcement

Collapse
No announcement yet.

Post functions don't recognize menu variables

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

  • Post functions don't recognize menu variables

    Hi,

    Help would be appreciated with a fix to this sample code. I would like to use the "edit studies" to select for printing or not printing to the "output window" (Alert.addToList) from "post function" code but nothing I have tried works.

    Thanks

    --------------------------------------------------------------------------
    var aFPArray = new Array();

    function preMain(){

    setPriceStudy(true);
    setStudyTitle("TestScript");
    setCursorLabelName("TestIt", 0);

    var x=0;

    aFPArray[x] = new FunctionParameter( "vTextOutput", FunctionParameter.BOOLEAN);
    with( aFPArray[x++] ) {
    setName( "Print Text Output" );
    setDefault( false );
    }

    }


    function main(vTextOutput) {

    var nState=getBarState();
    if (nState=BARSTATE_ALLBARS){
    TestFunction();
    }
    }

    function TestFunction()
    ...
    ...
    if (vAler = true){
    Alert.addToList("Don't Print this"));
    }
    }
    --------------------------------------------------------------------------

  • #2
    Re: Post functions don't recognize menu variables

    waynecd
    In order for it to work you need to pass the parameter vTextOutput to the function TestFunction when you are calling it. Also that function must include in its arguments the parameter (as you will use it in the conditional statement). The enclosed revision of your script should now work
    Alex

    PHP Code:
    var aFPArray = new Array(); 

    function 
    preMain(){

        
    setPriceStudy(true);
        
    setStudyTitle("TestScript");
        
    setCursorLabelName("TestIt"0);

        var 
    x=0

        
    aFPArray[x] = new FunctionParameter"vTextOutput"FunctionParameter.BOOLEAN); 
        
    withaFPArray[x++] ) { 
        
    setName"Print Text Output" ); 
        
    setDefaultfalse ); 
        } 
    }

    function 
    main(vTextOutput) {

        var 
    nState=getBarState();
        if (
    nState=BARSTATE_ALLBARS){
        
    TestFunction(vTextOutput);//added parameter 
        
    }
    }

    function 
    TestFunction(vAler){//added parameter and curly bracket

        
    if (vAler == true){//changed to == from =
            
    Alert.addToList("Don't Print this");//removed additional closing bracket
        
    }


    Originally posted by waynecd
    Hi,

    Help would be appreciated with a fix to this sample code. I would like to use the "edit studies" to select for printing or not printing to the "output window" (Alert.addToList) from "post function" code but nothing I have tried works.

    Thanks

    --------------------------------------------------------------------------
    var aFPArray = new Array();

    function preMain(){

    setPriceStudy(true);
    setStudyTitle("TestScript");
    setCursorLabelName("TestIt", 0);

    var x=0;

    aFPArray[x] = new FunctionParameter( "vTextOutput", FunctionParameter.BOOLEAN);
    with( aFPArray[x++] ) {
    setName( "Print Text Output" );
    setDefault( false );
    }

    }


    function main(vTextOutput) {

    var nState=getBarState();
    if (nState=BARSTATE_ALLBARS){
    TestFunction();
    }
    }

    function TestFunction()
    ...
    ...
    if (vAler = true){
    Alert.addToList("Don't Print this"));
    }
    }
    --------------------------------------------------------------------------

    Comment


    • #3
      Thanks

      Alex,

      Thanks so much. I thought I had tried that but I obviously did something wrong because it works fine with your input.

      I'll be more careful with syntax in my examples.

      Regards

      Wayne
      Last edited by waynecd; 02-08-2008, 08:00 PM.

      Comment


      • #4
        Re: Thanks

        Wayne
        You are most welcome
        Alex


        Originally posted by waynecd
        Alex,

        Thanks so much. I thought I had tried that but I obviously did something wrong because it works fine with your input.

        I'll be more careful with syntax in my examples.

        Regards

        Wayne

        Comment

        Working...
        X