Announcement

Collapse
No announcement yet.

parameter passing to main()

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

  • parameter passing to main()

    I can pass a parameter to a function within an efs fine.
    However, I'm having a problem with the parameter to main().
    I followed some examples but I guess I'm missing something.
    I loaded the efs below and did "edit studies" on it but the parameter caclType doesn't show up in the parameter list.
    Do I need something else?
    Thank you in advance.


    function main(calcType) {

    var nState = getBarState();
    var indcurr = getCurrentBarIndex();
    f((nState == BARSTATE_NEWBAR) ||
    (calcType = "now" && indcurr == 0))
    { ... }
    }

  • #2
    Hi,

    Your main statement looks fine.

    >function main(calcType) {

    I would set a default for calcType:

    If (calcType == null)
    calcType = "now";

    I also think you have a problem here:


    >var nState = getBarState();
    >var indcurr = getCurrentBarIndex();
    >if((nState == BARSTATE_NEWBAR) ||
    >(calcType = "now" && indcurr == 0))

    In that I suspect you want to say "calcType ==" rather than just "calcType =".




    }
    Last edited by gspiker; 03-03-2003, 02:18 PM.
    Garth

    Comment


    • #3
      oops. you're right about ==.
      however, problem remains where calcType doesn't appear in the formula parameters section of "edit studies".

      i added
      var calcType = "";
      function main(calcType) {
      debugPrintln("ct="+calcType)

      the display shows "undefined".

      Comment


      • #4
        Could you post your entire code?

        It would make debug easier.
        Garth

        Comment


        • #5
          Philtong:

          1. You need to unload and then re-load scripts when you add/remove main parameters for them to show up in Edit Studies

          2. You should not declare these parameters outside of main(). In your second message you showed:

          var calcType = "";
          function main(calcType) {
          debugPrintln("ct="+calcType)
          }

          Get rid of the first line (e.g., var calcType="") and it should work fine.

          Chris

          Comment


          • #6
            Thank you.

            Removing and Reloading did it.
            (also removed the var declaration.

            Comment

            Working...
            X